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 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
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)) {
ymc9 marked this conversation as resolved.
Show resolved Hide resolved
// foreign keys are not exposed as attributes
continue;
}
if (isRelationshipField(field)) {
let relType: string;
if (mode === 'create' || mode === 'update') {
Expand Down
29 changes: 0 additions & 29 deletions packages/plugins/openapi/tests/baseline/rest-3.0.0.baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2764,11 +2764,8 @@ components:
image:
type: string
nullable: true
userId:
type: string
required:
- image
- userId
relationships:
type: object
properties:
Expand All @@ -2791,14 +2788,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 +2823,6 @@ components:
image:
type: string
nullable: true
userId:
type: string
relationships:
type: object
properties:
Expand Down Expand Up @@ -2917,9 +2908,6 @@ components:
format: date-time
title:
type: string
authorId:
type: string
nullable: true
published:
type: boolean
viewCount:
Expand All @@ -2931,7 +2919,6 @@ components:
- createdAt
- updatedAt
- title
- authorId
- published
- viewCount
- notes
Expand Down Expand Up @@ -2974,9 +2961,6 @@ components:
format: date-time
title:
type: string
authorId:
type: string
nullable: true
published:
type: boolean
viewCount:
Expand Down Expand Up @@ -3022,9 +3006,6 @@ components:
format: date-time
title:
type: string
authorId:
type: string
nullable: true
published:
type: boolean
viewCount:
Expand Down Expand Up @@ -3108,16 +3089,6 @@ components:
type: string
type:
type: string
attributes:
type: object
properties:
postId:
type: string
userId:
type: string
required:
- postId
- userId
relationships:
type: object
properties:
Expand Down
32 changes: 0 additions & 32 deletions packages/plugins/openapi/tests/baseline/rest-3.1.0.baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2770,11 +2770,8 @@ components:
oneOf:
- type: 'null'
- type: string
userId:
type: string
required:
- image
- userId
relationships:
type: object
properties:
Expand All @@ -2797,15 +2794,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 +2831,6 @@ components:
oneOf:
- type: 'null'
- type: string
userId:
type: string
relationships:
type: object
properties:
Expand Down Expand Up @@ -2925,10 +2916,6 @@ components:
format: date-time
title:
type: string
authorId:
oneOf:
- type: 'null'
- type: string
published:
type: boolean
viewCount:
Expand All @@ -2941,7 +2928,6 @@ components:
- createdAt
- updatedAt
- title
- authorId
- published
- viewCount
- notes
Expand Down Expand Up @@ -2984,10 +2970,6 @@ components:
format: date-time
title:
type: string
authorId:
oneOf:
- type: 'null'
- type: string
published:
type: boolean
viewCount:
Expand Down Expand Up @@ -3034,10 +3016,6 @@ components:
format: date-time
title:
type: string
authorId:
oneOf:
- type: 'null'
- type: string
published:
type: boolean
viewCount:
Expand Down Expand Up @@ -3122,16 +3100,6 @@ components:
type: string
type:
type: string
attributes:
type: object
properties:
postId:
type: string
userId:
type: string
required:
- postId
- userId
relationships:
type: object
properties:
Expand Down
Loading