Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External references generate invalid code #863

Open
hugoArregui opened this issue May 17, 2023 · 2 comments
Open

External references generate invalid code #863

hugoArregui opened this issue May 17, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@hugoArregui
Copy link

hugoArregui commented May 17, 2023

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.

@anymaniax
Copy link
Collaborator

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

@hugoArregui
Copy link
Author

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!

@melloware melloware added the bug Something isn't working label Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants