I am having a base definitions and multiple concrete implementation using
'discriminator' field. When i set the fields mandatory in concrete
implementation and additionalProperties = false, swagger not validating
this condition and allowing user to skip mandatory field and allow
specifying additional fields which are not part of definitions. Below is
the sample definitions i have given for reference. To say, when using
Polymorphism ,
non of the validation is being done for concrete implementation. Only base
product gets validation because i have specified the base 'product' in my
Api body specification
Is the above condition bug in swagger validation or it's not supported?
*api layer*
*---------*
/companies/{companyId}/products:
post:
x-swagger-router-controller: product
operationId: create
description: |
xxxxxx.
parameters:
- name: companyId
in: path
description: ID of the `Company`
type: integer
required: true
- name: order
in: body
description: Payload
schema:
$ref: '#/definitions/Product'
tags:
- product
responses:
'200':
description: Successful response.
schema:
$ref: '#/definitions/Product'
default:
description: Error response.
schema:
$ref: '#/definitions/Error'
definitions:
Product:
type: object
required:
- type
discriminator: type
properties:
id:
type: string
description: Unique URI identifying this resource.
parent:
type: string
description: A reference to a Resource of which this Product is a
component.
readOnly: true
type:
description: The type of item being ordered.
type: string
enum:
- Create_X
- Create_Y
- Create_Z
Create_X:
allOf:
- $ref: '#/definitions/Product'
- type: object
required:
- resourceURI
- quantity
properties:
resourceURI:
type: string
description: Unique URI that is associated with the type of API
resource.
enum:
- http://xxxx.com/api/1/Product-Create-X
quantity:
description: The number of product instances ordered with the same
configuration
type: integer
format: int32
minimum: 1
additionalProperties: false
Create_Y:
allOf:
- $ref: '#/definitions/Product'
- type: object
required:
- resourceURI
- quantity
properties:
resourceURI:
type: string
description: Unique URI that is associated with the type of API
resource.
enum:
- http://xxxx.com/api/1/Product-Create-Y
quantity:
description: The number of product instances ordered with the same
configuration
type: integer
format: int32
minimum: 1
additionalProperties: false
Create_Z:
allOf:
- $ref: '#/definitions/Product'
- type: object
required:
- resourceURI
- quantity
properties:
resourceURI:
type: string
description: Unique URI that is associated with the type of API
resource.
enum:
- http://xxxx.com/api/1/Product-Create-Z
quantity:
description: The number of product instances ordered with the same
configuration
type: integer
format: int32
minimum: 1
additionalProperties: false
--
You received this message because you are subscribed to the Google Groups
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.