-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
OpenAPI shema definition for models should exclude hidden properties by default #4495
Comments
@ih84ds Thank you for the suggestion, it sounds reasonable to me. Take the Todo app as an example: Now the response schema of GET still uses the original model schema
the Todo schema in reference:
While the expected schema should be
|
I can think of two approaches:
|
I'm wondering why nobody Is working of this. Excluding hidden properties at controller level is redundant and lead to weirds generated schemas like this: export interface TodoExcludingSecretPropWithRelations {
id?: number;
title: string;
desc?: string;
} @jannyHou do you have any plan to sort it out? |
+1 for this, |
Hidden properties are automatically removed from the response data (model's toJSON() excludes the hidden properties), so it seems that the schema definition should also exclude these fields by default. Currently, one has to manually add these fields to the "exclude" option in
getModelSchemaRef()
Current behavior: hidden properties are removed from response data but openapi schema definition lists hidden properties in the schema.
Expected behavior: hidden properties are removed from response data and openapi schema definition does not list hidden properties.
The text was updated successfully, but these errors were encountered: