Class: Docit::SchemaGenerator
- Inherits:
-
Object
- Object
- Docit::SchemaGenerator
- Defined in:
- lib/docit/schema_generator.rb
Overview
Converts the Registry of operations and Configuration into an OpenAPI 3.0.3 spec hash.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.generate ⇒ Object
6 7 8 |
# File 'lib/docit/schema_generator.rb', line 6 def self.generate new.generate end |
Instance Method Details
#generate ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/docit/schema_generator.rb', line 10 def generate config = Docit.configuration spec = { openapi: "3.0.3", info: build_info(config), paths: build_paths, components: { securitySchemes: config.security_schemes } } # Top-level security applies to every operation unless an operation # overrides it (a documented scheme, or `security :none` to opt out). spec[:security] = config.default_security.map { |s| { s.to_s => [] } } if config.default_security? tag_defs = config. spec[:tags] = tag_defs if tag_defs.any? server_defs = config.servers spec[:servers] = server_defs if server_defs.any? schemas = build_component_schemas spec[:components][:schemas] = schemas if schemas.any? spec end |