-
Notifications
You must be signed in to change notification settings - Fork 230
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
Feature request: support #[schema(skip)]
#795
Comments
@magurotuna Sure, sounds a good idea, adding this kind of support should be quite easily done. Though I would make it as |
I ran into a similar use case today. |
Have a similar use case. @juhaku can I pick this up if this has not been implemented yet? |
I also have a similar use-case, where we e.g. use |
@Narayanbhat166 This has not been yet started working on, So please if there is time an energy, all contributions are welcome 🙂 |
Add support for `#[schema(ignore)]` for named field struct types implementing `ToSchema` trait. Add support for `param(ignore)` for named field structs implementing `IntoParams` trait. The ignored field will not get serialized to the OpenAPI schema. ```rust #[derive(ToSchema)] struct SchemaIgnoredField { value: String, #[schema(ignore)] __this_is_private: String, } #[derive(IntoParams)] #[into_params(parameter_in = Query)] struct Params { name: String, #[param(ignore)] __this_is_private: String, } ``` Closes #795
Add support for `#[schema(ignore)]` for named field struct types implementing `ToSchema` trait. Add support for `param(ignore)` for named field structs implementing `IntoParams` trait. The ignored field will not get serialized to the OpenAPI schema. ```rust #[derive(ToSchema)] struct SchemaIgnoredField { value: String, #[schema(ignore)] __this_is_private: String, } #[derive(IntoParams)] #[into_params(parameter_in = Query)] struct Params { name: String, #[param(ignore)] __this_is_private: String, } ``` Closes #795
Add support for `#[schema(ignore)]` for named field struct types implementing `ToSchema` trait. Add support for `param(ignore)` for named field structs implementing `IntoParams` trait. The ignored field will not get serialized to the OpenAPI schema. ```rust #[derive(ToSchema)] struct SchemaIgnoredField { value: String, #[schema(ignore)] __this_is_private: String, } #[derive(IntoParams)] #[into_params(parameter_in = Query)] struct Params { name: String, #[param(ignore)] __this_is_private: String, } ``` Closes #795
Add support for `#[schema(ignore)]` for named field struct types implementing `ToSchema` trait. Add support for `param(ignore)` for named field structs implementing `IntoParams` trait. The ignored field will not get serialized to the OpenAPI schema. ```rust #[derive(ToSchema)] struct SchemaIgnoredField { value: String, #[schema(ignore)] __this_is_private: String, } #[derive(IntoParams)] #[into_params(parameter_in = Query)] struct Params { name: String, #[param(ignore)] __this_is_private: String, } ``` Closes #795
Add support for `#[schema(ignore)]` for named field struct types implementing `ToSchema` trait. Add support for `param(ignore)` for named field structs implementing `IntoParams` trait. The ignored field will not get serialized to the OpenAPI schema. ```rust #[derive(ToSchema)] struct SchemaIgnoredField { value: String, #[schema(ignore)] __this_is_private: String, } #[derive(IntoParams)] #[into_params(parameter_in = Query)] struct Params { name: String, #[param(ignore)] __this_is_private: String, } ``` Closes #795
Now there is implementation coming up for this #1090 |
Add support for `#[schema(ignore)]` for named field struct types implementing `ToSchema` trait. Add support for `param(ignore)` for named field structs implementing `IntoParams` trait. The ignored field will not get serialized to the OpenAPI schema. ```rust #[derive(ToSchema)] struct SchemaIgnoredField { value: String, #[schema(ignore)] __this_is_private: String, } #[derive(IntoParams)] #[into_params(parameter_in = Query)] struct Params { name: String, #[param(ignore)] __this_is_private: String, } ``` Closes #795
Requested feature
Add support for
#[schema(skip)]
What this does
When this attribute is present, the target field or variant will not show up in the generated OpenAPI spec. This is like
#[serde(skip)]
, but the difference is that the proposed attribute doesn't affect how it is serialized.Background
We're using utoipa to generate OpenAPI spec based on API implementation written in Rust.
One unique point with our API is that it's used both externally and internally; for external users, the API must not make breaking changes while for internal purposes we may make some changes that can be breaking.
In order to achieve it, we use structs like below, which has
__internal
field that appears in the response body only if the request was made by an internal client.So essentially we would like to use
SecretStuff
as a schema, but we don't want it to show up in the OpenAPI spec because our OpenAPI spec serves as a public documentation of stable interfaces.With
#[schema(skip)]
, this would be accomplished by just adding this attribute to__secret
, like:The text was updated successfully, but these errors were encountered: