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

When using snake-case-fields and msgspec, field ordering does not always work correctly #1943

Open
ianbuss opened this issue May 1, 2024 · 0 comments · May be fixed by #1942
Open

When using snake-case-fields and msgspec, field ordering does not always work correctly #1943

ianbuss opened this issue May 1, 2024 · 0 comments · May be fixed by #1942

Comments

@ianbuss
Copy link

ianbuss commented May 1, 2024

Describe the bug
A clear and concise description of what the bug is.

To Reproduce

Example schema: https://raw.githubusercontent.com/kubernetes/kubernetes/release-1.28/api/openapi-spec/v3/api__v1_openapi.json

Used commandline:

$ datamodel-codegen --url 'https://raw.githubusercontent.com/kubernetes/kubernetes/release-1.28/api/openapi-spec/v3/api__v1_openapi.json' --output v1_28/ --output-model-type msgspec.Struct --snake-case-field --keep-model-order

Expected behavior
I expect field ordering to be required then optional fields. With snake-casing, the field ordering remains as it is in the source spec, which can result in import failures for generated models when optional fields appear before required fields.

Version:

  • OS: macOS
  • Python version: 3.11
  • datamodel-code-generator version: 0.25.6

Additional context
n/a

@ianbuss ianbuss linked a pull request May 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant