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: correct the format of the OpenAPI examples #2660

Merged
merged 12 commits into from
Nov 13, 2023
Merged

fix: correct the format of the OpenAPI examples #2660

merged 12 commits into from
Nov 13, 2023

Conversation

guacs
Copy link
Member

@guacs guacs commented Nov 12, 2023

Pull Request Checklist

  • New code has 100% test coverage
  • (If applicable) The prose documentation has been updated to reflect the changes introduced by this PR
  • (If applicable) The reference documentation has been updated to reflect the changes introduced by this PR
  • Pre-Commit Checks were ran and passed
  • Tests were ran and passed

Description

  • This PR fixes the format in which the examples are generated.

Close Issue(s)

@guacs guacs requested review from a team as code owners November 12, 2023 10:18
@guacs
Copy link
Member Author

guacs commented Nov 12, 2023

The OpenAPI schema requires examples to be in one of the following formats:

  • a list of the example values (this should be the values directly and must not include the metadata of an example)
  • a dictionary of the examples where the keys are the example name and the values are the example with the other metadata like the description, summary etc.

Reference: https://spec.openapis.org/oas/latest.html#requestBodyObject

@guacs
Copy link
Member Author

guacs commented Nov 12, 2023

For the following model:

@dataclass
class Foo:
    foo: int

Before:
image

After:
image

@guacs guacs enabled auto-merge (squash) November 13, 2023 05:32
Copy link

sonarcloud bot commented Nov 13, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@guacs guacs merged commit 680c2df into main Nov 13, 2023
16 checks passed
@guacs guacs deleted the openapi-examples branch November 13, 2023 05:39
Copy link

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/2660

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 this pull request may close these issues.

Bug: Incorrectly serialized examples in OpenAPI schema
4 participants