orval
orval copied to clipboard
External references generate invalid code
The complete example is in: https://github.com/hugoArregui/orval-test
What are the steps to reproduce this issue?
Let's say there is a path specification in which a reference is used for the schema and another for the example:
get:
operationId: getPeers
summary: List of peers
tags:
- Comms
description: >-
Retrieves the list peers in the server with details
about their positions and islands.
responses:
'200':
description: List of Peers
content:
application/json; charset=utf-8:
schema:
$ref: ../../components/schemas/comms/peers.yaml
examples:
ok:
$ref: ../../components/examples/comms/peers-ok.json
What happens?
The generated code contains two extra types:
export type Ok = PeersOk
export type Schema = Peers
What were you expecting to happen?
These two extra types should not be generated.
Any other comments?
This PR contains my attempt to fix the solution, but I'm not quite sure to understand the implications of this change, so although it works for my use case it may not be appropriate to apply it.
Your case is because orval is trying to resolve all the schema of non openapi file and your example is handle as a schema. Check here. Probably it could be solve by adding a better condition in that function
hello @anymaniax, thanks for the answer!, yes, I was able to trace it there but I was unable to come up with a better condition, if you have a particular suggestion I can try to work out a PR. Thanks again!