Skip to content

Commit

Permalink
Add Schema subclass Discriminator
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladas committed May 17, 2019
1 parent 07d8832 commit bdb90ed
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions lib/openapi_parser/schemas.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require_relative 'schemas/classes'

require_relative 'schemas/base'
require_relative 'schemas/discriminator'
require_relative 'schemas/openapi'
require_relative 'schemas/paths'
require_relative 'schemas/path_item'
Expand Down
1 change: 1 addition & 0 deletions lib/openapi_parser/schemas/classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module OpenAPIParser::Schemas
class Base; end
class Discriminator < Base; end
class OpenAPI < Base; end
class Operation < Base; end
class Parameter < Base; end
Expand Down
11 changes: 11 additions & 0 deletions lib/openapi_parser/schemas/discriminator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module OpenAPIParser::Schemas
class Discriminator < Base
# @!attribute [r] property_name
# @return [String, nil]
openapi_attr_value :property_name, schema_key: :propertyName

# @!attribute [r] mapping
# @return [Hash{String => String]
openapi_attr_value :mapping
end
end
12 changes: 2 additions & 10 deletions lib/openapi_parser/schemas/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,8 @@ class Schema < Base
openapi_attr_hash_object :properties, Schema, reference: true

# @!attribute [r] discriminator
# @return [Hash{String => Schema}, nil]
openapi_attr_objects :discriminator, Schema

# @!attribute [r] property_name
# @return [String, nil]
openapi_attr_value :property_name, schema_key: :propertyName

# @!attribute [r] mapping
# @return [Hash{String => String]
openapi_attr_value :mapping
# @return [Discriminator, nil]
openapi_attr_object :discriminator, Discriminator

# @!attribute [r] additional_properties
# @return [Boolean, Schema, Reference, nil]
Expand Down

0 comments on commit bdb90ed

Please sign in to comment.