why `OpenAPIParser::NotExistContentTypeDefinition` raised when using $ref in response
kochoru opened this issue · 7 comments
Environment
- openapi_parser
- version: 0.3.1
- OpenAPI Specification
- version: 3.0.1
- format: yaml
Situation
I'm trying to test using committee_rails
, but an error occurred when the definition like below.
responses:
200:
description: OK
content:
application/json:
schema:
type: object
properties:
hoge:
type: string
404:
$ref: '#/components/responses/NotFound'
and components/responses/NotFound
is:
components:
responses:
NotFound:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
and assert with assert_schema_conform
.
As a result, 200 OK test is passed, 404 Not Found test is failed with OpenAPIParser::NotExistContentTypeDefinition
Why is this behavior?
I can not find invalid parts, so I will investigate 🤔
Ok, I find a bug when we use Reference object in Responses Object.
Sorry, I'll fix 🙋
FYI: response with no return value raises same error
404:
description: "no resource found"
Hi, would you give me more information ?
Because your's definition doesn't have content type so rising the error is the correct behavior.
If you’re having trouble, I may be able to help if you give more details.
I faced to the same error and find the solution.
It seems the response requires content
even it is empty like this:
components:
responses:
'OK':
description: OK
content:
application/json: {}
Yes, I think there are different in the content type's response is empty and the content type isn't defined.
(i.e when the client request application/jsn
, it is bad request)
So when the content type isn't defined, we should raise error.