Module: Scorpio::OpenAPI::V3::Server
- Defined in:
- lib/scorpio/openapi/v3/server.rb
Overview
An object representing a Server.
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#serverObject
Instance Method Summary collapse
-
#expanded_url(given_server_variables) ⇒ Addressable::URI
expands this server's #url using the given_server_variables.
Instance Method Details
#expanded_url(given_server_variables) ⇒ Addressable::URI
expands this server's #url using the given_server_variables. any variables that are in the url but not in the given server variables are filled in using the default value for the variable.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/scorpio/openapi/v3/server.rb', line 18 def (given_server_variables) if variables server_variables = (given_server_variables.keys | variables.keys).map do |key| server_variable = variables[key] if server_variable && server_variable.enum unless server_variable.enum.include?(given_server_variables[key]) warn # TODO BLAME end end if given_server_variables.key?(key) {key => given_server_variables[key]} elsif server_variable.key?('default') {key => server_variable.default} else {} end end.inject({}, &:update) else server_variables = given_server_variables end template = Addressable::Template.new(url) template.(server_variables).freeze end |