Reputation: 87
I have a similar error to Swagger Schema error should NOT have additional properties, but in my case I'm referencing #/definitions so I'd appreciate some help.
I tried making an explicit object:
responses: '200': content: application/json schema: type: object properties: id: integer
and that gives me:
Schema error at paths['/user'].post.responses['200']
should NOT have additional properties
additionalProperty: content, schema
Jump to line 119
I also tried:
responses: '200': $ref: '#/definitions/UserCreateResponse'
and that gets me:
Semantic error at paths./user.post.responses.200.$ref
200 $refs cannot match any of the following: "#/definitions", "#/parameters"
Jump to line 120
The object shows up as desired if I use the $ref, but the error persists in the editor.
Upvotes: 1
Views: 4538
Reputation: 98011
Your first example is not valid. Change that to:
produces:
- application/json # <-- Response Content-Type is specified by "produces"
responses:
'200':
description: OK # <-- Each response code needs a "description"
schema:
type: object
properties:
id:
type: integer # <---
It's hard to say what caused the 2nd error (when using $ref
) because you did not post a complete spec.
Upvotes: 1
Reputation: 87
@Stijn pointed me towards a fix: write the code, then generate the Swagger code from that.
Also, using the online editor (linked from here: https://swagger.io/swagger-editor/) instead of my local Dockerized version solved the issue as well.
Upvotes: -2