Class: DryValidationOpenapi::SchemaBuilder
- Inherits:
-
Object
- Object
- DryValidationOpenapi::SchemaBuilder
- Defined in:
- lib/dry_validation_openapi/schema_builder.rb
Constant Summary collapse
- TYPE_MAPPING =
Maps dry-validation types to OpenAPI type (and optionally format) See: swagger.io/specification/#data-types
{ 'string' => :string, 'integer' => { type: :integer, format: 'int32' }, 'int' => { type: :integer, format: 'int32' }, 'float' => { type: :number, format: 'float' }, 'decimal' => { type: :number, format: 'double' }, 'number' => { type: :number, format: 'double' }, 'bool' => :boolean, 'boolean' => :boolean, 'date' => { type: :string, format: 'date' }, 'time' => { type: :string, format: 'date-time' }, 'date_time' => { type: :string, format: 'date-time' }, 'array' => :array, 'hash' => :object }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(contract_file_path) ⇒ SchemaBuilder
constructor
A new instance of SchemaBuilder.
Constructor Details
#initialize(contract_file_path) ⇒ SchemaBuilder
Returns a new instance of SchemaBuilder.
27 28 29 30 |
# File 'lib/dry_validation_openapi/schema_builder.rb', line 27 def initialize(contract_file_path) @contract_file_path = contract_file_path @definitions = [] end |
Class Method Details
.build(contract_file_path) ⇒ Object
23 24 25 |
# File 'lib/dry_validation_openapi/schema_builder.rb', line 23 def self.build(contract_file_path) new(contract_file_path).build end |
Instance Method Details
#build ⇒ Object
32 33 34 35 |
# File 'lib/dry_validation_openapi/schema_builder.rb', line 32 def build @definitions = ContractParser.parse_file(@contract_file_path) build_schema(@definitions) end |