Skip to content

Commit

Permalink
Change openapi create openapi to match server
Browse files Browse the repository at this point in the history
  • Loading branch information
thomassnielsen committed Nov 14, 2024
1 parent 510572d commit 057c73b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/plugins/openapi/src/rest-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
// For compound ids each component is also exposed as a separate fields for read operations,
// but not required for write operations
const fields =
idFields.length > 1 && mode === 'read' ? model.fields : model.fields.filter((f) => !isIdField(f));
idFields.length > 1 && mode !== 'update' ? model.fields : model.fields.filter((f) => !isIdField(f));

const attributes: Record<string, OAPI.SchemaObject> = {};
const relationships: Record<string, OAPI.ReferenceObject | OAPI.SchemaObject> = {};
Expand Down Expand Up @@ -907,7 +907,7 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
if (mode === 'create') {
// 'id' is required if there's no default value
const idFields = model.fields.filter((f) => isIdField(f));
if (idFields.length && idFields.every((f) => !hasAttribute(f, '@default'))) {
if (idFields.length === 1 && idFields.every((f) => !hasAttribute(f, '@default'))) {
properties = { id: { type: 'string' }, ...properties };
toplevelRequired.unshift('id');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3135,14 +3135,11 @@ components:
type: object
description: The "PostLike" model
required:
- id
- type
- attributes
properties:
type:
type: string
attributes:
type: object
relationships:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,6 @@ components:
type: object
description: The "PostLike" model
required:
- id
- type
- attributes
properties:
Expand Down

0 comments on commit 057c73b

Please sign in to comment.