Class: Apia::OpenApi::Specification
- Inherits:
-
Object
- Object
- Apia::OpenApi::Specification
- Includes:
- Helpers
- Defined in:
- lib/apia/open_api/specification.rb
Constant Summary collapse
- OPEN_API_VERSION =
The Ruby client generator currently only supports v3.0.0 openapi-generator.tech/
"3.0.0"
Instance Method Summary collapse
-
#initialize(api, base_url, name, additions = {}) ⇒ Specification
constructor
A new instance of Specification.
- #json ⇒ Object
Methods included from Helpers
#add_to_components_schemas, #convert_type_to_open_api_data_type, #formatted_description, #generate_array_schema, #generate_id_from_definition, #generate_scalar_schema, #generate_schema_ref
Constructor Details
#initialize(api, base_url, name, additions = {}) ⇒ Specification
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/apia/open_api/specification.rb', line 17 def initialize(api, base_url, name, additions = {}) default_additions = { info: {}, external_docs: {}, security_schemes: {} } additions = default_additions.merge(additions) @api = api @base_url = base_url @name = name || "Core" # will be suffixed with 'Api' and used in the client generator @spec = { openapi: OPEN_API_VERSION, info: additions[:info], externalDocs: additions[:external_docs], servers: [], paths: {}, components: { schemas: {} }, security: [], tags: [], "x-tagGroups": [] } if @spec[:externalDocs].nil? || @spec[:externalDocs].empty? @spec.delete(:externalDocs) end add_additional_security_schemes(additions[:security_schemes]) # path_ids is used to keep track of all the IDs of all the paths we've generated, to avoid duplicates # refer to the Path object for more info @path_ids = [] build_spec end |
Instance Method Details
#json ⇒ Object
50 51 52 |
# File 'lib/apia/open_api/specification.rb', line 50 def json JSON.pretty_generate(@spec) end |