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
feat(oas) - accurate model OAS representation - A to D #3203
Conversation
🦋 Changeset detectedLatest commit: a8fa726 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self-review: I'd recommend using the Model TS refactor PR to facilitate the review process. I've also create a demo PR to showcase the generate types from the OAS.
Has a dependency on #3198 getting merged in order for Redocly to not crash when rendering the circular references in this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a couple of comments. I also want to test out how it looks like in the documentation after merging the circular reference PR, since it's crashing now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I also tested the documentation and it works well
### Scope Models A to D ### What Refactor OAS for models to accurately represent their shape in API responses. ### Why About 33% of model fields are not accurately represented in the OAS. Most of the issues are: - fields that can not be omitted in the response are not declared as `required` - fields that could return `null` as their value are not declared as `nullable: true` When using a code generator, these OAS issues would lead to inaccurate response shapes in the generated client. ### How #### nullable Fields meeting at least one of the following condition will be represented as `nullable: true` in OAS: * The field is decorated with `@Column({ nullable: true })` * The field is decorated with `@OneToOne`, `@ManyToOne` * The field is decorated with `@DeleteDateColumn` #### optional Fields meeting at least one of the following conditions will never be listed as `required` in OAS and will be considered optional and could be omitted in the response: * The field is decorated with `@OneToOne`, `@ManyToOne`, `@OneToMany`, `@ManyToMany` * The field is decorated with `@FeatureFlagColumn` * The field is decorated with `@Column({select: false})` * The field is representing dynamic values not persisted in the database Fields not meeting any of the conditions above will be declared as `required` and are expected to be present in the response. ### Test * Ran OAS validator. * Ran docs build script. Expect OAS changes to be reflected in the API documentation.
Scope
Models A to D
What
Refactor OAS for models to accurately represent their shape in API responses.
Why
About 33% of model fields are not accurately represented in the OAS. Most of the issues are:
required
null
as their value are not declared asnullable: true
When using a code generator, these OAS issues would lead to inaccurate response shapes in the generated client.
How
nullable
Fields meeting at least one of the following condition will be represented as
nullable: true
in OAS:@Column({ nullable: true })
@OneToOne
,@ManyToOne
@DeleteDateColumn
optional
Fields meeting at least one of the following conditions will never be listed as
required
in OAS and will be considered optional and could be omitted in the response:@OneToOne
,@ManyToOne
,@OneToMany
,@ManyToMany
@FeatureFlagColumn
@Column({select: false})
Fields not meeting any of the conditions above will be declared as
required
and are expected to be present in the response.Test
Expect OAS changes to be reflected in the API documentation.