AnyOf doesn't work with additionalParameters
Issue #342
resolved
Hi,
I have a problem, because I would like to use anyOf
in path’s content but without using
.withLevelResolve(LevelResolverFactory.withAdditionalPropertiesIgnored())
, because It stops working another endpoint with discriminator. With disabled validation of additionalProperties you can put id
in both cases, but I want make it to be able only with certain type.
I have tried another solution described in FAQ ( with ParseOptions
) and It doesn’t work. Could you help with this problem ?
Example swagger spec:
openapi: 3.0.3
info:
title: Test app
version: alpha
servers:
- url: http://localhost:8080
paths:
/endpoint:
post:
requestBody:
required: true
content:
application/json:
schema:
anyOf:
- $ref: '#/components/schemas/ObjectWithName'
- $ref: '#/components/schemas/ObjectWithColor'
responses:
200:
description: Success
/endpointWithType:
post:
requestBody:
required: true
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/ObjectType1'
- $ref: '#/components/schemas/ObjectType2'
discriminator:
propertyName: type
mapping:
TYPE1: '#/components/schemas/ObjectType1'
TYPE2: '#/components/schemas/ObjectType2'
responses:
200:
description: Success
components:
schemas:
ObjectWithName:
type: object
properties:
common:
type: string
name:
type: string
required: [ name ]
ObjectWithColor:
type: object
properties:
common:
type: string
color:
type: string
required: [ color ]
ObjectType1:
type: object
properties:
id:
type: string
type:
type: string
enum:
- TYPE1
required: [ type, id ]
ObjectType2:
type: object
properties:
type:
type: string
enum:
- TYPE2
required: [ type ]
As a result I got known error message: "Object instance has properties which are not allowed by the schema: ["color","common"]"
Comments (2)
-
-
- changed status to resolved
- Log in to comment
A fix for issue
#336was recently released in v2.19.3I think from the looks of your spec that it will address your problem. Please test with the latest version and let me know if it fixes the problem. If not, feel free to re-open the issue.
Thanks.