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

Make referenced schemas required #1018

Merged
merged 1 commit into from
Sep 3, 2024
Merged

Make referenced schemas required #1018

merged 1 commit into from
Sep 3, 2024

Conversation

juhaku
Copy link
Owner

@juhaku juhaku commented Sep 2, 2024

This will affect in all places where schema is being rendered. These are value_type = .. request_body, response_body = ... to name few. This is still very much work in progress but aims to enforce PartialSchema implementation for every type that is being used in OpenAPI spec generated by utoipa.

The Schema trait will be split to PartialSchema and Schema and Schema will extend the PartialSchema trait. PartialSchema will provide the actual schema and Schema will provide name and other data related to the schema itself. This is useful since we already provide PartialSchema implementation for many standard Rust types and not all types need the full schema but only the schema definition. This makes schema definition implementation easier by juts allowing users to manually implement PartialSchema type for their type if needed. Still as usual the implementation can be automatically derived with ToSchema derive trait.

Fixes #500 Fixes #801

@juhaku juhaku added the enhancement New feature or request label Sep 2, 2024
@juhaku juhaku force-pushed the feature-required-schemas branch 2 times, most recently from 4db455a to 21e7d55 Compare September 3, 2024 11:19
@juhaku juhaku changed the title Wip make referenced schemas required Make referenced schemas required Sep 3, 2024
@juhaku juhaku force-pushed the feature-required-schemas branch 4 times, most recently from 30a8a5e to 8e8c7ad Compare September 3, 2024 11:42
@juhaku juhaku marked this pull request as ready for review September 3, 2024 11:42
This will affect in all places where schema is being rendered. These are
`value_type = ..` `request_body`, `response_body = ...` to name few.
This aims to enforce `PartialSchema` implementation for every type
that is being used in OpenAPI spec generated by utoipa.

The `Schema` trait will be split to `PartialSchema` and `Schema` and
`Schema` will extend the `PartialSchema` trait. `PartialSchema` will
provide the actual schema and `Schema` will provide name and other data
related to the schema itself. This is useful since we already provide
`PartialSchema` implementation for many standard Rust types and not all
types need the full schema but only the schema definition. This makes
schema definition implementation easier by juts allowing users to
manually implement `PartialSchema` type for their type if needed. Still
as usual the implementation can be automatically derived with `ToSchema`
derive trait.

Fixes #500 Fixes #801
@juhaku juhaku force-pushed the feature-required-schemas branch from 8e8c7ad to 42d40e9 Compare September 3, 2024 11:46
@juhaku juhaku merged commit b473b99 into master Sep 3, 2024
18 checks passed
@juhaku juhaku deleted the feature-required-schemas branch September 3, 2024 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Released
1 participant