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

fix(codegen): fixed calling order for WithAutoXOrder #3041

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fredbi
Copy link
Contributor

@fredbi fredbi commented Jan 3, 2024

This PR moves the call to WithAutoXOrder before we validate and flatten the spec for codegen purpose.

Other changes:

  • layout: moved all the spec massaging to a dedicated source
  • allowed WithAutoXOrder to report about errors rather than panicking

Overall, WithAutoXOrder is simplistic and could be improved a lot:

  • supporting JSON
  • supporting remote $refs, circular $refs
  • removing the dependency to yaml.v2
  • not producing a temporary file that hangs around
  • etc

These improvements are beyond the scope of this PR, which is just to fix responses. Perhaps a follow up could bring a more general solution to this problem.

@fredbi fredbi marked this pull request as draft January 3, 2024 14:06
@fredbi
Copy link
Contributor Author

fredbi commented Jan 3, 2024

@casualjim @youyuanwu I realize that a lot of work about "keeping things ordered" has already been accomplished in swag.

I believe this is the way to solve this issue (and many other unreported ones) for good.
IMHO, the "WithAutoXOrder()" hack in go-swagger should disappear and be replaced by appropriate spec loaders (-> in "loads") that inject the "x-order" when loading each document (local or remote, YAML or JSON).
Working on that now. Looks like there is quite a loaded plate...

@fredbi fredbi force-pushed the fix/2949-keep-spec-order branch 2 times, most recently from 74ca358 to 13b79e7 Compare January 7, 2024 08:47
This PR moves the call to WithAutoXOrder _before_ we validate and
flatten the spec for codegen purpose.

* fixes go-swagger#2949

Other changes:
* layout: moved all the spec massaging to a dedicated source
* allowed WithAutoXOrder to report about errors rather than panicking

Overall, WithAutoXOrder is simplistic and could be improved a lot:
* supporting JSON
* supporting remote $refs, circular $refs
* removing the dependency to yaml.v2
* not producing a temporary file that hangs around
* etc

These improvements are beyond the scope of this PR, which is just to
fix responses. Perhaps a follow up could bring a more general solution to this problem.

Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use of --keep-spec-order leads to empty response structs in v0.30.5
1 participant