Skip to content

Commit e9d7f84

Browse files
committed
Fixed: links in resource object must not be required
1 parent e1cafc9 commit e9d7f84

File tree

14 files changed

+1
-98
lines changed

14 files changed

+1
-98
lines changed

src/Examples/JsonApiDotNetCoreExample/GeneratedSwagger/JsonApiDotNetCoreExample.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5255,9 +5255,6 @@
52555255
"$ref": "#/components/schemas/dataInResponse"
52565256
},
52575257
{
5258-
"required": [
5259-
"links"
5260-
],
52615258
"type": "object",
52625259
"properties": {
52635260
"attributes": {
@@ -5647,9 +5644,6 @@
56475644
"$ref": "#/components/schemas/dataInResponse"
56485645
},
56495646
{
5650-
"required": [
5651-
"links"
5652-
],
56535647
"type": "object",
56545648
"properties": {
56555649
"attributes": {
@@ -6157,9 +6151,6 @@
61576151
"$ref": "#/components/schemas/dataInResponse"
61586152
},
61596153
{
6160-
"required": [
6161-
"links"
6162-
],
61636154
"type": "object",
61646155
"properties": {
61656156
"attributes": {

src/JsonApiDotNetCore.OpenApi/JsonApiObjects/ResourceObjects/ResourceDataInResponse.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.ComponentModel.DataAnnotations;
21
using System.Text.Json.Serialization;
32
using JetBrains.Annotations;
43
using JsonApiDotNetCore.OpenApi.JsonApiObjects.Links;
@@ -16,7 +15,7 @@ internal sealed class ResourceDataInResponse<TResource> : ResourceData
1615
[JsonPropertyName("relationships")]
1716
public RelationshipsInResponse<TResource> Relationships { get; set; } = null!;
1817

19-
[Required]
18+
// This would normally be { "self": "/people/5" } for GET /todoItems/1/assignee, but it is null when PeopleController is unavailable.
2019
[JsonPropertyName("links")]
2120
public LinksInResourceData Links { get; set; } = null!;
2221

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,6 @@
498498
"$ref": "#/components/schemas/dataInResponse"
499499
},
500500
{
501-
"required": [
502-
"links"
503-
],
504501
"type": "object",
505502
"properties": {
506503
"attributes": {
@@ -728,9 +725,6 @@
728725
"$ref": "#/components/schemas/dataInResponse"
729726
},
730727
{
731-
"required": [
732-
"links"
733-
],
734728
"type": "object",
735729
"properties": {
736730
"attributes": {
@@ -820,9 +814,6 @@
820814
"$ref": "#/components/schemas/dataInResponse"
821815
},
822816
{
823-
"required": [
824-
"links"
825-
],
826817
"type": "object",
827818
"properties": {
828819
"attributes": {

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,9 +1259,6 @@
12591259
"$ref": "#/components/schemas/dataInResponse"
12601260
},
12611261
{
1262-
"required": [
1263-
"links"
1264-
],
12651262
"type": "object",
12661263
"properties": {
12671264
"attributes": {
@@ -1601,9 +1598,6 @@
16011598
"$ref": "#/components/schemas/dataInResponse"
16021599
},
16031600
{
1604-
"required": [
1605-
"links"
1606-
],
16071601
"type": "object",
16081602
"properties": {
16091603
"attributes": {

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6047,9 +6047,6 @@
60476047
"$ref": "#/components/schemas/data-in-response"
60486048
},
60496049
{
6050-
"required": [
6051-
"links"
6052-
],
60536050
"type": "object",
60546051
"properties": {
60556052
"attributes": {
@@ -6532,9 +6529,6 @@
65326529
"$ref": "#/components/schemas/data-in-response"
65336530
},
65346531
{
6535-
"required": [
6536-
"links"
6537-
],
65386532
"type": "object",
65396533
"properties": {
65406534
"attributes": {
@@ -7009,9 +7003,6 @@
70097003
"$ref": "#/components/schemas/data-in-response"
70107004
},
70117005
{
7012-
"required": [
7013-
"links"
7014-
],
70157006
"type": "object",
70167007
"properties": {
70177008
"attributes": {
@@ -7727,9 +7718,6 @@
77277718
"$ref": "#/components/schemas/data-in-response"
77287719
},
77297720
{
7730-
"required": [
7731-
"links"
7732-
],
77337721
"type": "object",
77347722
"properties": {
77357723
"attributes": {

test/OpenApiTests/LegacyOpenApi/expected-swagger.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6047,9 +6047,6 @@
60476047
"$ref": "#/components/schemas/data-in-response"
60486048
},
60496049
{
6050-
"required": [
6051-
"links"
6052-
],
60536050
"type": "object",
60546051
"properties": {
60556052
"attributes": {
@@ -6532,9 +6529,6 @@
65326529
"$ref": "#/components/schemas/data-in-response"
65336530
},
65346531
{
6535-
"required": [
6536-
"links"
6537-
],
65386532
"type": "object",
65396533
"properties": {
65406534
"attributes": {
@@ -7009,9 +7003,6 @@
70097003
"$ref": "#/components/schemas/data-in-response"
70107004
},
70117005
{
7012-
"required": [
7013-
"links"
7014-
],
70157006
"type": "object",
70167007
"properties": {
70177008
"attributes": {
@@ -7727,9 +7718,6 @@
77277718
"$ref": "#/components/schemas/data-in-response"
77287719
},
77297720
{
7730-
"required": [
7731-
"links"
7732-
],
77337721
"type": "object",
77347722
"properties": {
77357723
"attributes": {

test/OpenApiTests/NamingConventions/CamelCase/GeneratedSwagger/swagger.g.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3083,9 +3083,6 @@
30833083
"$ref": "#/components/schemas/dataInResponse"
30843084
},
30853085
{
3086-
"required": [
3087-
"links"
3088-
],
30893086
"type": "object",
30903087
"properties": {
30913088
"attributes": {
@@ -3491,9 +3488,6 @@
34913488
"$ref": "#/components/schemas/dataInResponse"
34923489
},
34933490
{
3494-
"required": [
3495-
"links"
3496-
],
34973491
"type": "object",
34983492
"properties": {
34993493
"attributes": {

test/OpenApiTests/NamingConventions/KebabCase/GeneratedSwagger/swagger.g.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3083,9 +3083,6 @@
30833083
"$ref": "#/components/schemas/data-in-response"
30843084
},
30853085
{
3086-
"required": [
3087-
"links"
3088-
],
30893086
"type": "object",
30903087
"properties": {
30913088
"attributes": {
@@ -3491,9 +3488,6 @@
34913488
"$ref": "#/components/schemas/data-in-response"
34923489
},
34933490
{
3494-
"required": [
3495-
"links"
3496-
],
34973491
"type": "object",
34983492
"properties": {
34993493
"attributes": {

test/OpenApiTests/NamingConventions/PascalCase/GeneratedSwagger/swagger.g.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3083,9 +3083,6 @@
30833083
"$ref": "#/components/schemas/DataInResponse"
30843084
},
30853085
{
3086-
"required": [
3087-
"links"
3088-
],
30893086
"type": "object",
30903087
"properties": {
30913088
"attributes": {
@@ -3491,9 +3488,6 @@
34913488
"$ref": "#/components/schemas/DataInResponse"
34923489
},
34933490
{
3494-
"required": [
3495-
"links"
3496-
],
34973491
"type": "object",
34983492
"properties": {
34993493
"attributes": {

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3475,9 +3475,6 @@
34753475
"$ref": "#/components/schemas/dataInResponse"
34763476
},
34773477
{
3478-
"required": [
3479-
"links"
3480-
],
34813478
"type": "object",
34823479
"properties": {
34833480
"attributes": {
@@ -3820,9 +3817,6 @@
38203817
"$ref": "#/components/schemas/dataInResponse"
38213818
},
38223819
{
3823-
"required": [
3824-
"links"
3825-
],
38263820
"type": "object",
38273821
"properties": {
38283822
"attributes": {

test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedSwagger/swagger.g.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,9 +2570,6 @@
25702570
"$ref": "#/components/schemas/dataInResponse"
25712571
},
25722572
{
2573-
"required": [
2574-
"links"
2575-
],
25762573
"type": "object",
25772574
"properties": {
25782575
"links": {
@@ -3223,9 +3220,6 @@
32233220
"$ref": "#/components/schemas/dataInResponse"
32243221
},
32253222
{
3226-
"required": [
3227-
"links"
3228-
],
32293223
"type": "object",
32303224
"properties": {
32313225
"attributes": {

test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedSwagger/swagger.g.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,9 +2570,6 @@
25702570
"$ref": "#/components/schemas/dataInResponse"
25712571
},
25722572
{
2573-
"required": [
2574-
"links"
2575-
],
25762573
"type": "object",
25772574
"properties": {
25782575
"links": {
@@ -3284,9 +3281,6 @@
32843281
"$ref": "#/components/schemas/dataInResponse"
32853282
},
32863283
{
3287-
"required": [
3288-
"links"
3289-
],
32903284
"type": "object",
32913285
"properties": {
32923286
"attributes": {

test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedSwagger/swagger.g.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3402,9 +3402,6 @@
34023402
"$ref": "#/components/schemas/dataInResponse"
34033403
},
34043404
{
3405-
"required": [
3406-
"links"
3407-
],
34083405
"type": "object",
34093406
"properties": {
34103407
"links": {
@@ -4145,9 +4142,6 @@
41454142
"$ref": "#/components/schemas/dataInResponse"
41464143
},
41474144
{
4148-
"required": [
4149-
"links"
4150-
],
41514145
"type": "object",
41524146
"properties": {
41534147
"attributes": {

test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedSwagger/swagger.g.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3402,9 +3402,6 @@
34023402
"$ref": "#/components/schemas/dataInResponse"
34033403
},
34043404
{
3405-
"required": [
3406-
"links"
3407-
],
34083405
"type": "object",
34093406
"properties": {
34103407
"links": {
@@ -4139,9 +4136,6 @@
41394136
"$ref": "#/components/schemas/dataInResponse"
41404137
},
41414138
{
4142-
"required": [
4143-
"links"
4144-
],
41454139
"type": "object",
41464140
"properties": {
41474141
"attributes": {

0 commit comments

Comments
 (0)