Skip to content

Commit 057c73b

Browse files
Change openapi create openapi to match server
1 parent 510572d commit 057c73b

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
860860
// For compound ids each component is also exposed as a separate fields for read operations,
861861
// but not required for write operations
862862
const fields =
863-
idFields.length > 1 && mode === 'read' ? model.fields : model.fields.filter((f) => !isIdField(f));
863+
idFields.length > 1 && mode !== 'update' ? model.fields : model.fields.filter((f) => !isIdField(f));
864864

865865
const attributes: Record<string, OAPI.SchemaObject> = {};
866866
const relationships: Record<string, OAPI.ReferenceObject | OAPI.SchemaObject> = {};
@@ -907,7 +907,7 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
907907
if (mode === 'create') {
908908
// 'id' is required if there's no default value
909909
const idFields = model.fields.filter((f) => isIdField(f));
910-
if (idFields.length && idFields.every((f) => !hasAttribute(f, '@default'))) {
910+
if (idFields.length === 1 && idFields.every((f) => !hasAttribute(f, '@default'))) {
911911
properties = { id: { type: 'string' }, ...properties };
912912
toplevelRequired.unshift('id');
913913
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3135,14 +3135,11 @@ components:
31353135
type: object
31363136
description: The "PostLike" model
31373137
required:
3138-
- id
31393138
- type
31403139
- attributes
31413140
properties:
31423141
type:
31433142
type: string
3144-
attributes:
3145-
type: object
31463143
relationships:
31473144
type: object
31483145
properties:

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3149,7 +3149,6 @@ components:
31493149
type: object
31503150
description: The "PostLike" model
31513151
required:
3152-
- id
31533152
- type
31543153
- attributes
31553154
properties:

0 commit comments

Comments
 (0)