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

Add option to output unsorted schema #7767

Closed

Conversation

vigneshmanick
Copy link

@vigneshmanick vigneshmanick commented Oct 7, 2023

Change Summary

Add toggle so that the schema output model_dump can be sorted or unsorted. The sorting was added in #6043.

Related issue number

#7580

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer: @davidhewitt

- add unit tests
@vigneshmanick
Copy link
Author

@sydney-runkle have tried to create an option for unsorted output. Let me know if this is ok or totally off the mark :)

Please review

Copy link
Member

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vigneshmanick - looks great overall - just a few change requests.

Thanks so much for your contribution - I'm sure this feature will be highly appreciated 😄.

docs/concepts/json_schema.md Show resolved Hide resolved
Comment on lines +444 to +445
else:
return json_schema
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
else:
return json_schema
return json_schema

Comment on lines +4267 to +4268
def generate(self, schema, mode='validation', sort_schema=True):
json_schema = super().generate(schema, mode=mode, sort_schema=sort_schema)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a section to this test that verifies the operation of the sort_schema=False flag in the case of a custom generate json schema function?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean parameterize the flag?

@sydney-runkle
Copy link
Member

@adriangb, could you take a look at this PR? Others on the team mentioned that you've contributed significantly to the sorting logic, so would love to get your input 😄.

@sydney-runkle
Copy link
Member

Closing in favor of #7817

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.

None yet

3 participants