Skip to content

Commit 13d3914

Browse files
Don’t expose FKs as attributes
1 parent 85a8d5d commit 13d3914

File tree

3 files changed

+4
-61
lines changed

3 files changed

+4
-61
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,10 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
868868
const required: string[] = [];
869869

870870
for (const field of fields) {
871+
if (isForeignKeyField(field)) {
872+
// foreign keys are not exposed as attributes
873+
continue;
874+
}
871875
if (isRelationshipField(field)) {
872876
let relType: string;
873877
if (mode === 'create' || mode === 'update') {

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

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,11 +2764,8 @@ components:
27642764
image:
27652765
type: string
27662766
nullable: true
2767-
userId:
2768-
type: string
27692767
required:
27702768
- image
2771-
- userId
27722769
relationships:
27732770
type: object
27742771
properties:
@@ -2791,14 +2788,10 @@ components:
27912788
type: string
27922789
attributes:
27932790
type: object
2794-
required:
2795-
- userId
27962791
properties:
27972792
image:
27982793
type: string
27992794
nullable: true
2800-
userId:
2801-
type: string
28022795
relationships:
28032796
type: object
28042797
properties:
@@ -2830,8 +2823,6 @@ components:
28302823
image:
28312824
type: string
28322825
nullable: true
2833-
userId:
2834-
type: string
28352826
relationships:
28362827
type: object
28372828
properties:
@@ -2917,9 +2908,6 @@ components:
29172908
format: date-time
29182909
title:
29192910
type: string
2920-
authorId:
2921-
type: string
2922-
nullable: true
29232911
published:
29242912
type: boolean
29252913
viewCount:
@@ -2931,7 +2919,6 @@ components:
29312919
- createdAt
29322920
- updatedAt
29332921
- title
2934-
- authorId
29352922
- published
29362923
- viewCount
29372924
- notes
@@ -2974,9 +2961,6 @@ components:
29742961
format: date-time
29752962
title:
29762963
type: string
2977-
authorId:
2978-
type: string
2979-
nullable: true
29802964
published:
29812965
type: boolean
29822966
viewCount:
@@ -3022,9 +3006,6 @@ components:
30223006
format: date-time
30233007
title:
30243008
type: string
3025-
authorId:
3026-
type: string
3027-
nullable: true
30283009
published:
30293010
type: boolean
30303011
viewCount:
@@ -3108,16 +3089,6 @@ components:
31083089
type: string
31093090
type:
31103091
type: string
3111-
attributes:
3112-
type: object
3113-
properties:
3114-
postId:
3115-
type: string
3116-
userId:
3117-
type: string
3118-
required:
3119-
- postId
3120-
- userId
31213092
relationships:
31223093
type: object
31233094
properties:

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2770,11 +2770,8 @@ components:
27702770
oneOf:
27712771
- type: 'null'
27722772
- type: string
2773-
userId:
2774-
type: string
27752773
required:
27762774
- image
2777-
- userId
27782775
relationships:
27792776
type: object
27802777
properties:
@@ -2797,15 +2794,11 @@ components:
27972794
type: string
27982795
attributes:
27992796
type: object
2800-
required:
2801-
- userId
28022797
properties:
28032798
image:
28042799
oneOf:
28052800
- type: 'null'
28062801
- type: string
2807-
userId:
2808-
type: string
28092802
relationships:
28102803
type: object
28112804
properties:
@@ -2838,8 +2831,6 @@ components:
28382831
oneOf:
28392832
- type: 'null'
28402833
- type: string
2841-
userId:
2842-
type: string
28432834
relationships:
28442835
type: object
28452836
properties:
@@ -2925,10 +2916,6 @@ components:
29252916
format: date-time
29262917
title:
29272918
type: string
2928-
authorId:
2929-
oneOf:
2930-
- type: 'null'
2931-
- type: string
29322919
published:
29332920
type: boolean
29342921
viewCount:
@@ -2941,7 +2928,6 @@ components:
29412928
- createdAt
29422929
- updatedAt
29432930
- title
2944-
- authorId
29452931
- published
29462932
- viewCount
29472933
- notes
@@ -2984,10 +2970,6 @@ components:
29842970
format: date-time
29852971
title:
29862972
type: string
2987-
authorId:
2988-
oneOf:
2989-
- type: 'null'
2990-
- type: string
29912973
published:
29922974
type: boolean
29932975
viewCount:
@@ -3034,10 +3016,6 @@ components:
30343016
format: date-time
30353017
title:
30363018
type: string
3037-
authorId:
3038-
oneOf:
3039-
- type: 'null'
3040-
- type: string
30413019
published:
30423020
type: boolean
30433021
viewCount:
@@ -3122,16 +3100,6 @@ components:
31223100
type: string
31233101
type:
31243102
type: string
3125-
attributes:
3126-
type: object
3127-
properties:
3128-
postId:
3129-
type: string
3130-
userId:
3131-
type: string
3132-
required:
3133-
- postId
3134-
- userId
31353103
relationships:
31363104
type: object
31373105
properties:

0 commit comments

Comments
 (0)