You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on an OpenAPI code generator and I'm using GitHub's spec as a primary example. I've covered all of the paths and schemas except for the following construct where properties and anyOf are used on the same level (see operationId: gists/update):
requestBody:
required: truecontent:
application/json:
schema:
properties:
description:
description: Description of the gistexample: Example Ruby scripttype: stringfiles:
description: Names of files to be updatedexample:
hello.rb:
content: blahfilename: goodbye.rbtype: objectadditionalProperties:
type: objectnullable: trueproperties:
content:
description: The new content of the filetype: stringfilename:
description: The new filename for the filetype: stringnullable: trueanyOf:
- required:
- content
- required:
- filename
- type: objectmaxProperties: 0anyOf:
- required:
- description
- required:
- filestype: objectnullable: true
If I put this schema in Swagger Editor, it fails to produce a comprehensible result.
I'm not sure if that construct is allowed in OpenAPI. At least I couldn't find any examples of this outside of GitHub spec.
If you take a step back and think about the intention behind this schema, isn't it the same thing as the following:
requestBody:
required: truecontent:
application/json:
schema:
type: objectproperties:
description:
description: Description of the gistexample: Example Ruby scripttype: stringnullable: truefiles:
description: Names of files to be updatedexample:
hello.rb:
content: blahfilename: goodbye.rbtype: objectnullable: trueadditionalProperties:
type: objectproperties:
content:
description: The new content of the filetype: stringfilename:
description: The new filename for the filetype: stringrequired:
- content
It's a much simpler definition and this is what the code generator produces for me with the update schema:
publicstructPatchRequest:Encodable{/// Description of the gist////// Example: "Example Ruby script"publicvardescription:String?/// Names of files to be updated////// Example:////// {/// "hello.rb" : {/// "content" : "blah",/// "filename" : "goodbye.rb"/// }/// }publicvarfiles:[String:File]?publicstructFile:Encodable{/// The new content of the filepublicvarcontent:String/// The new filename for the filepublicvarfilename:String?publicinit(content:String, filename:String?=nil){self.content = content
self.filename = filename
}}publicinit(description:String?=nil, files:[String:File]?=nil){self.description = description
self.files = files
}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I'm working on an OpenAPI code generator and I'm using GitHub's spec as a primary example. I've covered all of the paths and schemas except for the following construct where
properties
andanyOf
are used on the same level (see operationId:gists/update
):If I put this schema in Swagger Editor, it fails to produce a comprehensible result.
I'm not sure if that construct is allowed in OpenAPI. At least I couldn't find any examples of this outside of GitHub spec.
If you take a step back and think about the intention behind this schema, isn't it the same thing as the following:
It's a much simpler definition and this is what the code generator produces for me with the update schema:
Beta Was this translation helpful? Give feedback.
All reactions