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

Don't expose foreign keys as attributes in openAPI spec #1856

Merged
merged 3 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions packages/plugins/openapi/src/rest-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,10 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
const required: string[] = [];

for (const field of fields) {
if (isForeignKeyField(field) && mode !== 'read') {
// foreign keys are not exposed as attributes
continue;
}
if (isRelationshipField(field)) {
let relType: string;
if (mode === 'create' || mode === 'update') {
Expand Down
12 changes: 0 additions & 12 deletions packages/plugins/openapi/tests/baseline/rest-3.0.0.baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2791,14 +2791,10 @@ components:
type: string
attributes:
type: object
required:
- userId
properties:
image:
type: string
nullable: true
userId:
type: string
relationships:
type: object
properties:
Expand Down Expand Up @@ -2830,8 +2826,6 @@ components:
image:
type: string
nullable: true
userId:
type: string
relationships:
type: object
properties:
Expand Down Expand Up @@ -2974,9 +2968,6 @@ components:
format: date-time
title:
type: string
authorId:
type: string
nullable: true
published:
type: boolean
viewCount:
Expand Down Expand Up @@ -3022,9 +3013,6 @@ components:
format: date-time
title:
type: string
authorId:
type: string
nullable: true
published:
type: boolean
viewCount:
Expand Down
14 changes: 0 additions & 14 deletions packages/plugins/openapi/tests/baseline/rest-3.1.0.baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2797,15 +2797,11 @@ components:
type: string
attributes:
type: object
required:
- userId
properties:
image:
oneOf:
- type: 'null'
- type: string
userId:
type: string
relationships:
type: object
properties:
Expand Down Expand Up @@ -2838,8 +2834,6 @@ components:
oneOf:
- type: 'null'
- type: string
userId:
type: string
relationships:
type: object
properties:
Expand Down Expand Up @@ -2984,10 +2978,6 @@ components:
format: date-time
title:
type: string
authorId:
oneOf:
- type: 'null'
- type: string
published:
type: boolean
viewCount:
Expand Down Expand Up @@ -3034,10 +3024,6 @@ components:
format: date-time
title:
type: string
authorId:
oneOf:
- type: 'null'
- type: string
published:
type: boolean
viewCount:
Expand Down
Loading