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

Enhance unit type support #476

Merged
merged 1 commit into from
Feb 9, 2023
Merged

Enhance unit type support #476

merged 1 commit into from
Feb 9, 2023

Conversation

juhaku
Copy link
Owner

@juhaku juhaku commented Feb 9, 2023

Use centralized empty schema to create schema for unit type structs and unit enum variants. Add helper function for creating an empty Schema. Create TupleUnit type alias for () (unit type) that can be used as a reference where ever needed if added to the OpenApi schema.

Centralized TupleUnit within the OpenAPI doc will render as nullable Schema since () will render as null in JSON.

 #[derive(utoipa::OpenApi)]
 #[openapi(components(schemas(utoipa::TupleUnit)))]
 struct ApiDoc;

Fixes #448, Relates #464

Use centralized empty schema to create schema for unit type structs and
unit enum variants. Add helper function for creating an empty `Schema`.
Create `TupleUnit` type alias for `()` _(unit type)_ that can be used as
a reference where ever needed if added to the OpenApi schema.

Centralized `TupleUnit` within the OpenAPI doc will render as
`nullable` Schema since `()` will render as `null` in JSON.
```rust
 #[derive(utoipa::OpenApi)]
 #[openapi(components(schemas(utoipa::TupleUnit)))]
 struct ApiDoc;
```
@juhaku juhaku merged commit 2986e5a into master Feb 9, 2023
@juhaku juhaku deleted the enahce-unit-type branch February 9, 2023 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
Development

Successfully merging this pull request may close these issues.

Support for unit type
1 participant