openapiutils

package
v0.22.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2019 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHostFromURL added in v0.1.5

func GetHostFromURL(url string) string

GetHostFromURL returns the fqdn of a given string (localhost including port number is also handled). Example domains that would match: - http://domain.com/ - domain.com/parameter - domain.com?anything - example.domain.com - example.domain-hyphen.com - www.domain.com - localhost - localhost:8080 - 127.0.0.1 - 127.0.0.1:8080 - 127.0.0.1 - http://127.0.0.1:8080/swagger.com

func GetMultiRegionHost added in v0.9.0

func GetMultiRegionHost(overrideHost string, region string) (string, error)

GetMultiRegionHost builds a final fqdn based on the given host that is parameterised (${1}%s$4) and injects the given region in it

func GetSchemaDefinition added in v0.3.1

func GetSchemaDefinition(definitions map[string]spec.Schema, ref string) (*spec.Schema, error)

GetSchemaDefinition queries the definitions and tries to find the schema definition for the given ref. If the schema definition the ref value is pointing at does not exist and error is returned. Otherwise, the corresponding schema definition is returned.

func IsMultiRegionHost added in v0.9.0

func IsMultiRegionHost(overrideHost string) (bool, *regexp.Regexp)

IsMultiRegionHost checks whether the override host is parameterised following the format expected

func IsValidHost added in v0.10.0

func IsValidHost(url string) bool

IsValidHost checks whether the given string is a valid host. A valid host is considered a FQDN or IP. The latter may include also non starndar ports in the strings e,g: - domain.com - domain.com:8080 - localhost - localhost:8443 - 127.0.0.1 - 127.0.0.1:8080 Note that if custom ports are used, the protocol used would still be the one defined in the swagger doc. Hence, if https is the default protocol as specified in swagger, a host like www.domain.com:8080 would still use https protocol.

func StringExtensionExists added in v0.3.0

func StringExtensionExists(extensions spec.Extensions, key string) (string, bool)

StringExtensionExists tries to find a match using the built-in extensions GetString method and if there is no match it will try to find a match without converting the key lower case (as done behind the scenes by GetString method). Context: The Extensions look up methods tweaks the given key making it lower case and then trying to match against the keys in the map. However this may not always work as the Extensions might have been added without going through the Add method which lower cases the key, though in situations where the struct was un-marshaled directly instead this translation would not have happened and therefore the look up queiry will not find matches

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL