Skip to content

Commit b38f195

Browse files
committed
Fixed: do not emit AdditionalProperties on relationshipName and resourceType enums
1 parent 22f6d92 commit b38f195

File tree

21 files changed

+74
-148
lines changed

21 files changed

+74
-148
lines changed

src/Examples/JsonApiDotNetCoreExample/GeneratedSwagger/JsonApiDotNetCoreExample.json

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6071,8 +6071,7 @@
60716071
"enum": [
60726072
"assignedTodoItems"
60736073
],
6074-
"type": "string",
6075-
"additionalProperties": false
6074+
"type": "string"
60766075
},
60776076
"personAttributesInResponse": {
60786077
"type": "object",
@@ -6292,8 +6291,7 @@
62926291
"enum": [
62936292
"ownedTodoItems"
62946293
],
6295-
"type": "string",
6296-
"additionalProperties": false
6294+
"type": "string"
62976295
},
62986296
"personPrimaryResponseDocument": {
62996297
"required": [
@@ -6356,8 +6354,7 @@
63566354
"enum": [
63576355
"people"
63586356
],
6359-
"type": "string",
6360-
"additionalProperties": false
6357+
"type": "string"
63616358
},
63626359
"personSecondaryResponseDocument": {
63636360
"required": [
@@ -7007,8 +7004,7 @@
70077004
"enum": [
70087005
"tags"
70097006
],
7010-
"type": "string",
7011-
"additionalProperties": false
7007+
"type": "string"
70127008
},
70137009
"tagTodoItemsRelationshipIdentifier": {
70147010
"required": [
@@ -7047,8 +7043,7 @@
70477043
"enum": [
70487044
"todoItems"
70497045
],
7050-
"type": "string",
7051-
"additionalProperties": false
7046+
"type": "string"
70527047
},
70537048
"toManyTagInRequest": {
70547049
"required": [
@@ -7212,8 +7207,7 @@
72127207
"enum": [
72137208
"assignee"
72147209
],
7215-
"type": "string",
7216-
"additionalProperties": false
7210+
"type": "string"
72177211
},
72187212
"todoItemAttributesInResponse": {
72197213
"type": "object",
@@ -7445,8 +7439,7 @@
74457439
"enum": [
74467440
"owner"
74477441
],
7448-
"type": "string",
7449-
"additionalProperties": false
7442+
"type": "string"
74507443
},
74517444
"todoItemPrimaryResponseDocument": {
74527445
"required": [
@@ -7524,8 +7517,7 @@
75247517
"enum": [
75257518
"todoItems"
75267519
],
7527-
"type": "string",
7528-
"additionalProperties": false
7520+
"type": "string"
75297521
},
75307522
"todoItemTagsRelationshipIdentifier": {
75317523
"required": [
@@ -7564,8 +7556,7 @@
75647556
"enum": [
75657557
"tags"
75667558
],
7567-
"type": "string",
7568-
"additionalProperties": false
7559+
"type": "string"
75697560
},
75707561
"updateOperationCode": {
75717562
"enum": [

src/JsonApiDotNetCore.OpenApi.Swashbuckle/SchemaGenerators/Components/RelationshipNameSchemaGenerator.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public OpenApiSchema GenerateSchema(RelationshipAttribute relationship, SchemaRe
3838
var fullSchema = new OpenApiSchema
3939
{
4040
Type = "string",
41-
Enum = [new OpenApiString(relationship.PublicName)],
42-
AdditionalPropertiesAllowed = false
41+
Enum = [new OpenApiString(relationship.PublicName)]
4342
};
4443

4544
return schemaRepository.AddDefinition(schemaId, fullSchema);

src/JsonApiDotNetCore.OpenApi.Swashbuckle/SchemaGenerators/Components/ResourceTypeSchemaGenerator.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ public OpenApiSchema GenerateSchema(ResourceType resourceType, SchemaRepository
2929
var fullSchema = new OpenApiSchema
3030
{
3131
Type = "string",
32-
Enum = [new OpenApiString(resourceType.PublicName)],
33-
AdditionalPropertiesAllowed = false
32+
Enum = [new OpenApiString(resourceType.PublicName)]
3433
};
3534

3635
string schemaId = _schemaIdSelector.GetResourceTypeSchemaId(resourceType);

test/OpenApiTests/AtomicOperations/GeneratedSwagger/swagger.g.json

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6838,8 +6838,7 @@
68386838
"enum": [
68396839
"enrollments"
68406840
],
6841-
"type": "string",
6842-
"additionalProperties": false
6841+
"type": "string"
68436842
},
68446843
"courseIdentifierCollectionResponseDocument": {
68456844
"required": [
@@ -7031,8 +7030,7 @@
70317030
"enum": [
70327031
"courses"
70337032
],
7034-
"type": "string",
7035-
"additionalProperties": false
7033+
"type": "string"
70367034
},
70377035
"courseSecondaryResponseDocument": {
70387036
"required": [
@@ -7115,8 +7113,7 @@
71157113
"enum": [
71167114
"taughtBy"
71177115
],
7118-
"type": "string",
7119-
"additionalProperties": false
7116+
"type": "string"
71207117
},
71217118
"createCourseOperation": {
71227119
"allOf": [
@@ -7822,8 +7819,7 @@
78227819
"enum": [
78237820
"course"
78247821
],
7825-
"type": "string",
7826-
"additionalProperties": false
7822+
"type": "string"
78277823
},
78287824
"enrollmentDataInResponse": {
78297825
"allOf": [
@@ -8027,8 +8023,7 @@
80278023
"enum": [
80288024
"enrollments"
80298025
],
8030-
"type": "string",
8031-
"additionalProperties": false
8026+
"type": "string"
80328027
},
80338028
"enrollmentStudentRelationshipIdentifier": {
80348029
"required": [
@@ -8067,8 +8062,7 @@
80678062
"enum": [
80688063
"student"
80698064
],
8070-
"type": "string",
8071-
"additionalProperties": false
8065+
"type": "string"
80728066
},
80738067
"errorLinks": {
80748068
"type": "object",
@@ -8952,8 +8946,7 @@
89528946
"enum": [
89538947
"enrollments"
89548948
],
8955-
"type": "string",
8956-
"additionalProperties": false
8949+
"type": "string"
89578950
},
89588951
"studentIdentifierCollectionResponseDocument": {
89598952
"required": [
@@ -9114,8 +9107,7 @@
91149107
"enum": [
91159108
"mentor"
91169109
],
9117-
"type": "string",
9118-
"additionalProperties": false
9110+
"type": "string"
91199111
},
91209112
"studentPrimaryResponseDocument": {
91219113
"required": [
@@ -9185,8 +9177,7 @@
91859177
"enum": [
91869178
"students"
91879179
],
9188-
"type": "string",
9189-
"additionalProperties": false
9180+
"type": "string"
91909181
},
91919182
"studentSecondaryResponseDocument": {
91929183
"required": [
@@ -9459,8 +9450,7 @@
94599450
"enum": [
94609451
"mentors"
94619452
],
9462-
"type": "string",
9463-
"additionalProperties": false
9453+
"type": "string"
94649454
},
94659455
"teacherPrimaryResponseDocument": {
94669456
"required": [
@@ -9530,8 +9520,7 @@
95309520
"enum": [
95319521
"teachers"
95329522
],
9533-
"type": "string",
9534-
"additionalProperties": false
9523+
"type": "string"
95359524
},
95369525
"teacherTeachesRelationshipIdentifier": {
95379526
"required": [
@@ -9570,8 +9559,7 @@
95709559
"enum": [
95719560
"teaches"
95729561
],
9573-
"type": "string",
9574-
"additionalProperties": false
9562+
"type": "string"
95759563
},
95769564
"toManyCourseInRequest": {
95779565
"required": [

test/OpenApiTests/AtomicOperations/OperationsTests.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,7 @@ public async Task Course_operation_component_schemas_are_exposed()
751751
"enum": [
752752
"enrollments"
753753
],
754-
"type": "string",
755-
"additionalProperties": false
754+
"type": "string"
756755
}
757756
""");
758757
});
@@ -1246,8 +1245,7 @@ public async Task Student_operation_component_schemas_are_exposed()
12461245
"enum": [
12471246
"mentor"
12481247
],
1249-
"type": "string",
1250-
"additionalProperties": false
1248+
"type": "string"
12511249
}
12521250
""");
12531251

@@ -1292,8 +1290,7 @@ public async Task Student_operation_component_schemas_are_exposed()
12921290
"enum": [
12931291
"enrollments"
12941292
],
1295-
"type": "string",
1296-
"additionalProperties": false
1293+
"type": "string"
12971294
}
12981295
""");
12991296
});
@@ -1776,8 +1773,7 @@ public async Task Teacher_operation_component_schemas_are_exposed()
17761773
"enum": [
17771774
"mentors"
17781775
],
1779-
"type": "string",
1780-
"additionalProperties": false
1776+
"type": "string"
17811777
}
17821778
""");
17831779
});
@@ -2182,8 +2178,7 @@ public async Task Enrollment_operation_component_schemas_are_exposed()
21822178
"enum": [
21832179
"course"
21842180
],
2185-
"type": "string",
2186-
"additionalProperties": false
2181+
"type": "string"
21872182
}
21882183
""");
21892184
});

test/OpenApiTests/ClientIdGenerationModes/GeneratedSwagger/swagger.g.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,7 @@
802802
"enum": [
803803
"games"
804804
],
805-
"type": "string",
806-
"additionalProperties": false
805+
"type": "string"
807806
},
808807
"meta": {
809808
"type": "object",
@@ -1027,8 +1026,7 @@
10271026
"enum": [
10281027
"playerGroups"
10291028
],
1030-
"type": "string",
1031-
"additionalProperties": false
1029+
"type": "string"
10321030
},
10331031
"playerIdentifierInRequest": {
10341032
"required": [
@@ -1135,8 +1133,7 @@
11351133
"enum": [
11361134
"players"
11371135
],
1138-
"type": "string",
1139-
"additionalProperties": false
1136+
"type": "string"
11401137
},
11411138
"relationshipLinks": {
11421139
"type": "object",

test/OpenApiTests/Headers/GeneratedSwagger/swagger.g.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,8 +1332,7 @@
13321332
"enum": [
13331333
"countries"
13341334
],
1335-
"type": "string",
1336-
"additionalProperties": false
1335+
"type": "string"
13371336
},
13381337
"createCountryRequestDocument": {
13391338
"required": [
@@ -1729,8 +1728,7 @@
17291728
"enum": [
17301729
"languages"
17311730
],
1732-
"type": "string",
1733-
"additionalProperties": false
1731+
"type": "string"
17341732
},
17351733
"meta": {
17361734
"type": "object",

test/OpenApiTests/LegacyOpenApi/GeneratedSwagger/swagger.g.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6072,8 +6072,7 @@
60726072
"enum": [
60736073
"airplanes"
60746074
],
6075-
"type": "string",
6076-
"additionalProperties": false
6075+
"type": "string"
60776076
},
60786077
"attributes-in-create-airplane-request": {
60796078
"required": [
@@ -6981,8 +6980,7 @@
69816980
"enum": [
69826981
"flight-attendants"
69836982
],
6984-
"type": "string",
6985-
"additionalProperties": false
6983+
"type": "string"
69866984
},
69876985
"flight-attendant-secondary-response-document": {
69886986
"required": [
@@ -7316,8 +7314,7 @@
73167314
"enum": [
73177315
"flights"
73187316
],
7319-
"type": "string",
7320-
"additionalProperties": false
7317+
"type": "string"
73217318
},
73227319
"jsonapi": {
73237320
"type": "object",
@@ -7708,8 +7705,7 @@
77087705
"enum": [
77097706
"passengers"
77107707
],
7711-
"type": "string",
7712-
"additionalProperties": false
7708+
"type": "string"
77137709
},
77147710
"relationship-links": {
77157711
"type": "object",

0 commit comments

Comments
 (0)