Sha256: 0ffa620665680fbdb955817a21a289078869874d4bb1815536efbf84e0a8470f
Contents?: true
Size: 1014 Bytes
Versions: 11
Compression:
Stored size: 1014 Bytes
Contents
module OpenApi module DSL # https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/ # https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject class CombinedSchema < Hash attr_accessor :processed def initialize(combined_schema) self.processed = { } combined_schema.delete_if { |_, v| v.nil? } @mode = combined_schema.keys.first.to_s.sub('_not', 'not').camelize(:lower).to_sym @schemas = combined_schema.values.first end def process(options = { inside_desc: false }) processed[@mode] = @schemas.map do |schema| type = schema.is_a?(Hash) ? schema[:type] : schema schema = { } unless schema.is_a?(Hash) SchemaObj.new(type, schema).process(options) end processed end end end end __END__ Inside schema: "oneOf": [ { "$ref": "#components/schemas/DogSchema" }, { "type": "string" }, { "type": "integer" } ]
Version data entries
11 entries across 11 versions & 1 rubygems