-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
The current implementation is not able to handle object properties that are defined using "allOf"
"allOf" is supported at the root of definitions through the "ComposedModel", but not much anywhere else.
The following example cannot be deserialized properly:
definitions:
standaloneDef:
type: object
description: Standalone
properties:
name:
type: string
description: name
defWithDep:
type: object
description: With dep
required:
- id
properties:
id:
type: string
description: id
example: "0x00"
def:
type: object
allOf:
- $ref: "#/definitions/standaloneDef"
- type: object
properties:
otherProp:
type: string
The 'def' attribute in 'defWithDep' ends up with no property at all after deserialization. It is read as the following:
{
"swagger" : "2.0",
"info" : {
"version" : "0.0.1",
"title" : "..."
},
"basePath" : "...",
"paths" : {},
"definitions" : {
"standaloneDef" : {
"type" : "object",
"properties" : {
"name" : {
"type" : "string",
"description" : "name"
}
},
"description" : "Standalone"
},
"defWithDep" : {
"type" : "object",
"required" : [ "id" ],
"properties" : {
"id" : {
"type" : "string",
"example" : "0x00",
"description" : "id"
},
"def" : {
"type" : "object",
"properties" : { }
}
},
"description" : "With dep"
}
},
"parameters" : { },
"responses" : { }
}
Regarding how I ended up in this scenario is because of a long time running conversation here: vendor extensions next to references. I need to do the following:
defWithDep:
type: object
properties:
def:
$ref: "#/definitions/standaloneDef"
x-thingy: thing
but the (one of the) only way to do it, is by using allOf:
defWithDep:
type: object
properties:
def:
x-thingy: thing
allOf:
- $ref: "#/definitions/standaloneDef"
which is - afaik - compliant with the spec (swagger editor manages it well)
Julien-Eyraud, Tiller and dvallejo
Metadata
Metadata
Assignees
Labels
No labels