Skip to content

Commit b39b1d1

Browse files
Update openapi spec to match
1 parent f54fbcb commit b39b1d1

File tree

3 files changed

+3
-34
lines changed

3 files changed

+3
-34
lines changed

packages/plugins/openapi/src/rest-generator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,9 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
847847

848848
private generateModelEntity(model: DataModel, mode: 'read' | 'create' | 'update'): OAPI.SchemaObject {
849849
const idFields = model.fields.filter((f) => isIdField(f));
850-
// For compound ids, each component is also exposed as a separate field
851-
const fields = idFields.length > 1 ? model.fields : model.fields.filter((f) => !isIdField(f));
850+
// For compound ids, each component is also exposed as a separate fields for read operations
851+
const fields =
852+
idFields.length > 1 && mode === 'read' ? model.fields : model.fields.filter((f) => !isIdField(f));
852853

853854
const attributes: Record<string, OAPI.SchemaObject> = {};
854855
const relationships: Record<string, OAPI.ReferenceObject | OAPI.SchemaObject> = {};

packages/plugins/openapi/tests/baseline/rest-3.0.0.baseline.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,14 +3143,6 @@ components:
31433143
type: string
31443144
attributes:
31453145
type: object
3146-
required:
3147-
- postId
3148-
- userId
3149-
properties:
3150-
postId:
3151-
type: string
3152-
userId:
3153-
type: string
31543146
relationships:
31553147
type: object
31563148
properties:
@@ -3178,13 +3170,6 @@ components:
31783170
type: string
31793171
type:
31803172
type: string
3181-
attributes:
3182-
type: object
3183-
properties:
3184-
postId:
3185-
type: string
3186-
userId:
3187-
type: string
31883173
relationships:
31893174
type: object
31903175
properties:

packages/plugins/openapi/tests/baseline/rest-3.1.0.baseline.yaml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3155,16 +3155,6 @@ components:
31553155
properties:
31563156
type:
31573157
type: string
3158-
attributes:
3159-
type: object
3160-
required:
3161-
- postId
3162-
- userId
3163-
properties:
3164-
postId:
3165-
type: string
3166-
userId:
3167-
type: string
31683158
relationships:
31693159
type: object
31703160
properties:
@@ -3192,13 +3182,6 @@ components:
31923182
type: string
31933183
type:
31943184
type: string
3195-
attributes:
3196-
type: object
3197-
properties:
3198-
postId:
3199-
type: string
3200-
userId:
3201-
type: string
32023185
relationships:
32033186
type: object
32043187
properties:

0 commit comments

Comments
 (0)