orval-labs / orval

orval is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in yaml or json formats. 🍺
https://orval.dev
MIT License
2.8k stars 312 forks source link

Types in generated react-query schema have unstable order, causing noisy diffs #1382

Open severinh opened 3 months ago

severinh commented 3 months ago

What are the steps to reproduce this issue?

I don't have a minimally reproducible example, but here's what happens in our project:

  1. Generate the *.schema.ts output of type react-query from some OpenAPI schema.
  2. Add a new component in the OpenAPI schema.
  3. Re-generate *.schemas.ts.

What happens?

The newly added component correctly appears as a new type in the generated schema. However, the order of the other types in the generated schema changes unnecessarily, and seemingly at random. As a result, the diff of the schema is noisy, and it significantly increases the size of the PRs with schema changes.

What were you expecting to happen?

I expected the new type to appear in the generated schemas.ts file, with the order of the other types staying the same.

Any logs, error output, etc?

No specific log output, but here's a screenshot of it happening in our project: Types moved around, even though they had nothing to do with the change to the OpenAPI schema. image

Any other comments?

I don't know how orval is implemented. But I suspect that the instability could come from modelling the component names as a hash set, where the order is not stable.

What versions are you using?

Operating System: MacOS 14.4.1 Package Version: 6.26.0 Browser Version: Node.js 20

melloware commented 3 months ago

@severinh do you have a PR to fix?