Sha256: dbb02202f8caae1f0cb85faf1e28b3fa241c37cf0e5d8f5eda5a2dc487975ad1
Contents?: true
Size: 950 Bytes
Versions: 3
Compression:
Stored size: 950 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_for(param_name = nil, options = { desc_inside: false }) processed.tap do |it| it[@mode] = @schemas.map do |schema| type = schema.is_a?(Hash) ? schema[:type] : schema schema = { } unless schema.is_a?(Hash) SchemaObj.new(type, schema).process_for(param_name, options) end end end alias process process_for end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
zero-rails_openapi-1.4.2 | lib/oas_objs/combined_schema.rb |
zero-rails_openapi-1.4.1 | lib/oas_objs/combined_schema.rb |
zero-rails_openapi-1.4.0 | lib/oas_objs/combined_schema.rb |