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

Mark openapi attributes as required for reads #1772

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/plugins/openapi/src/rest-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,9 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
!(isDataModel(field.$resolvedType?.decl) && field.type.array)
) {
required.push(field.name);
} else if (mode === 'read') {
// Until we support sparse fieldsets, all fields are required for read
required.push(field.name);
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions packages/plugins/openapi/tests/baseline/rest-3.0.0.baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2591,6 +2591,11 @@ components:
type: string
role:
$ref: '#/components/schemas/role'
required:
- createdAt
- updatedAt
- email
- role
relationships:
type: object
properties:
Expand Down Expand Up @@ -2761,6 +2766,9 @@ components:
nullable: true
userId:
type: string
required:
- image
- userId
relationships:
type: object
properties:
Expand Down Expand Up @@ -2919,6 +2927,14 @@ components:
notes:
type: string
nullable: true
required:
- createdAt
- updatedAt
- title
- authorId
- published
- viewCount
- notes
relationships:
type: object
properties:
Expand Down Expand Up @@ -3099,6 +3115,9 @@ components:
type: string
userId:
type: string
required:
- postId
- userId
relationships:
type: object
properties:
Expand Down
19 changes: 19 additions & 0 deletions packages/plugins/openapi/tests/baseline/rest-3.1.0.baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2596,6 +2596,11 @@ components:
type: string
role:
$ref: '#/components/schemas/role'
required:
- createdAt
- updatedAt
- email
- role
relationships:
type: object
properties:
Expand Down Expand Up @@ -2767,6 +2772,9 @@ components:
- type: string
userId:
type: string
required:
- image
- userId
relationships:
type: object
properties:
Expand Down Expand Up @@ -2929,6 +2937,14 @@ components:
oneOf:
- type: 'null'
- type: string
required:
- createdAt
- updatedAt
- title
- authorId
- published
- viewCount
- notes
relationships:
type: object
properties:
Expand Down Expand Up @@ -3113,6 +3129,9 @@ components:
type: string
userId:
type: string
required:
- postId
- userId
relationships:
type: object
properties:
Expand Down
Loading