From e3dc622fc3be1fb04347754a65c1033d94433d36 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Tue, 24 Oct 2023 01:15:28 +0200 Subject: [PATCH] Fix order of JSON:API properties in OAS document --- .../JsonApiObjectPropertyName.cs | 14 - ...lableResourceIdentifierResponseDocument.cs | 6 +- ...llableSecondaryResourceResponseDocument.cs | 6 +- .../PrimaryResourceResponseDocument.cs | 6 +- .../ResourceCollectionResponseDocument.cs | 6 +- ...rceIdentifierCollectionResponseDocument.cs | 6 +- .../ResourceIdentifierResponseDocument.cs | 6 +- .../SecondaryResourceResponseDocument.cs | 6 +- ...sInResourceIdentifierCollectionDocument.cs | 6 +- .../LinksInResourceIdentifierDocument.cs | 6 +- .../JsonApiPropertyName.cs | 17 ++ .../JsonApiSchemaGenerator.cs | 20 +- .../OpenApiSchemaExtensions.cs | 26 ++ .../ResourceFieldObjectSchemaBuilder.cs | 16 +- .../ResourceObjectSchemaGenerator.cs | 51 ++-- .../LegacyClient/swagger.g.json | 210 +++++++------- .../CamelCase/swagger.g.json | 126 ++++----- .../KebabCase/swagger.g.json | 126 ++++----- .../PascalCase/swagger.g.json | 126 ++++----- .../ModelStateValidationOff/swagger.g.json | 96 +++---- .../ModelStateValidationOn/swagger.g.json | 126 ++++----- .../ModelStateValidationOff/swagger.g.json | 126 ++++----- .../ModelStateValidationOn/swagger.g.json | 126 ++++----- .../LegacyOpenApiIntegration/swagger.json | 262 +++++++++--------- 24 files changed, 779 insertions(+), 743 deletions(-) delete mode 100644 src/JsonApiDotNetCore.OpenApi/JsonApiObjectPropertyName.cs create mode 100644 src/JsonApiDotNetCore.OpenApi/JsonApiPropertyName.cs create mode 100644 src/JsonApiDotNetCore.OpenApi/SwaggerComponents/OpenApiSchemaExtensions.cs diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjectPropertyName.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjectPropertyName.cs deleted file mode 100644 index dd6248eadd..0000000000 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjectPropertyName.cs +++ /dev/null @@ -1,14 +0,0 @@ -#pragma warning disable AV1008 // Class should not be static - -namespace JsonApiDotNetCore.OpenApi; - -internal static class JsonApiObjectPropertyName -{ - public const string Type = "type"; - public const string Id = "id"; - public const string Data = "data"; - public const string AttributesObject = "attributes"; - public const string RelationshipsObject = "relationships"; - public const string MetaObject = "meta"; - public const string LinksObject = "links"; -} diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/NullableResourceIdentifierResponseDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/NullableResourceIdentifierResponseDocument.cs index ca04d0f853..1d46bd26cd 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/NullableResourceIdentifierResponseDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/NullableResourceIdentifierResponseDocument.cs @@ -13,13 +13,13 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; internal sealed class NullableResourceIdentifierResponseDocument : NullableSingleData> where TResource : IIdentifiable { - [JsonPropertyName("meta")] - public IDictionary Meta { get; set; } = null!; - [JsonPropertyName("jsonapi")] public JsonapiObject Jsonapi { get; set; } = null!; [Required] [JsonPropertyName("links")] public LinksInResourceIdentifierDocument Links { get; set; } = null!; + + [JsonPropertyName("meta")] + public IDictionary Meta { get; set; } = null!; } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/NullableSecondaryResourceResponseDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/NullableSecondaryResourceResponseDocument.cs index 93334854e0..4c141e55c5 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/NullableSecondaryResourceResponseDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/NullableSecondaryResourceResponseDocument.cs @@ -11,13 +11,13 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; internal sealed class NullableSecondaryResourceResponseDocument : NullableSingleData> where TResource : IIdentifiable { - [JsonPropertyName("meta")] - public IDictionary Meta { get; set; } = null!; - [JsonPropertyName("jsonapi")] public JsonapiObject Jsonapi { get; set; } = null!; [Required] [JsonPropertyName("links")] public LinksInResourceDocument Links { get; set; } = null!; + + [JsonPropertyName("meta")] + public IDictionary Meta { get; set; } = null!; } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/PrimaryResourceResponseDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/PrimaryResourceResponseDocument.cs index fd34d149d9..f66048a422 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/PrimaryResourceResponseDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/PrimaryResourceResponseDocument.cs @@ -11,13 +11,13 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; internal sealed class PrimaryResourceResponseDocument : SingleData> where TResource : IIdentifiable { - [JsonPropertyName("meta")] - public IDictionary Meta { get; set; } = null!; - [JsonPropertyName("jsonapi")] public JsonapiObject Jsonapi { get; set; } = null!; [Required] [JsonPropertyName("links")] public LinksInResourceDocument Links { get; set; } = null!; + + [JsonPropertyName("meta")] + public IDictionary Meta { get; set; } = null!; } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceCollectionResponseDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceCollectionResponseDocument.cs index 7547718523..109c2cde50 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceCollectionResponseDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceCollectionResponseDocument.cs @@ -11,13 +11,13 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; internal sealed class ResourceCollectionResponseDocument : ManyData> where TResource : IIdentifiable { - [JsonPropertyName("meta")] - public IDictionary Meta { get; set; } = null!; - [JsonPropertyName("jsonapi")] public JsonapiObject Jsonapi { get; set; } = null!; [Required] [JsonPropertyName("links")] public LinksInResourceCollectionDocument Links { get; set; } = null!; + + [JsonPropertyName("meta")] + public IDictionary Meta { get; set; } = null!; } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceIdentifierCollectionResponseDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceIdentifierCollectionResponseDocument.cs index f2b0f3a885..d0b7ca4422 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceIdentifierCollectionResponseDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceIdentifierCollectionResponseDocument.cs @@ -11,13 +11,13 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; internal sealed class ResourceIdentifierCollectionResponseDocument : ManyData> where TResource : IIdentifiable { - [JsonPropertyName("meta")] - public IDictionary Meta { get; set; } = null!; - [JsonPropertyName("jsonapi")] public JsonapiObject Jsonapi { get; set; } = null!; [Required] [JsonPropertyName("links")] public LinksInResourceIdentifierCollectionDocument Links { get; set; } = null!; + + [JsonPropertyName("meta")] + public IDictionary Meta { get; set; } = null!; } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceIdentifierResponseDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceIdentifierResponseDocument.cs index 1c99cbd517..dd479129fb 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceIdentifierResponseDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/ResourceIdentifierResponseDocument.cs @@ -11,13 +11,13 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; internal sealed class ResourceIdentifierResponseDocument : SingleData> where TResource : IIdentifiable { - [JsonPropertyName("meta")] - public IDictionary Meta { get; set; } = null!; - [JsonPropertyName("jsonapi")] public JsonapiObject Jsonapi { get; set; } = null!; [Required] [JsonPropertyName("links")] public LinksInResourceIdentifierDocument Links { get; set; } = null!; + + [JsonPropertyName("meta")] + public IDictionary Meta { get; set; } = null!; } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/SecondaryResourceResponseDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/SecondaryResourceResponseDocument.cs index c048b34dfb..e895e2c22d 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/SecondaryResourceResponseDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Documents/SecondaryResourceResponseDocument.cs @@ -11,13 +11,13 @@ namespace JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; internal sealed class SecondaryResourceResponseDocument : SingleData> where TResource : IIdentifiable { - [JsonPropertyName("meta")] - public IDictionary Meta { get; set; } = null!; - [JsonPropertyName("jsonapi")] public JsonapiObject Jsonapi { get; set; } = null!; [Required] [JsonPropertyName("links")] public LinksInResourceDocument Links { get; set; } = null!; + + [JsonPropertyName("meta")] + public IDictionary Meta { get; set; } = null!; } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Links/LinksInResourceIdentifierCollectionDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Links/LinksInResourceIdentifierCollectionDocument.cs index a13a6175b9..839dde99b8 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Links/LinksInResourceIdentifierCollectionDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Links/LinksInResourceIdentifierCollectionDocument.cs @@ -11,13 +11,13 @@ internal sealed class LinksInResourceIdentifierCollectionDocument [JsonPropertyName("self")] public string Self { get; set; } = null!; - [JsonPropertyName("describedby")] - public string Describedby { get; set; } = null!; - [Required] [JsonPropertyName("related")] public string Related { get; set; } = null!; + [JsonPropertyName("describedby")] + public string Describedby { get; set; } = null!; + [Required] [JsonPropertyName("first")] public string First { get; set; } = null!; diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Links/LinksInResourceIdentifierDocument.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Links/LinksInResourceIdentifierDocument.cs index 9304162d0f..94814316f6 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Links/LinksInResourceIdentifierDocument.cs +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiObjects/Links/LinksInResourceIdentifierDocument.cs @@ -11,10 +11,10 @@ internal sealed class LinksInResourceIdentifierDocument [JsonPropertyName("self")] public string Self { get; set; } = null!; - [JsonPropertyName("describedby")] - public string Describedby { get; set; } = null!; - [Required] [JsonPropertyName("related")] public string Related { get; set; } = null!; + + [JsonPropertyName("describedby")] + public string Describedby { get; set; } = null!; } diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiPropertyName.cs b/src/JsonApiDotNetCore.OpenApi/JsonApiPropertyName.cs new file mode 100644 index 0000000000..906015e40b --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiPropertyName.cs @@ -0,0 +1,17 @@ +#pragma warning disable AV1008 // Class should not be static + +namespace JsonApiDotNetCore.OpenApi; + +internal static class JsonApiPropertyName +{ + public const string Jsonapi = "jsonapi"; + public const string Links = "links"; + public const string Data = "data"; + public const string Type = "type"; + public const string Id = "id"; + public const string Attributes = "attributes"; + public const string Relationships = "relationships"; + public const string Errors = "errors"; + public const string Included = "included"; + public const string Meta = "meta"; +} diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs index 1e8efa8452..fb5435062d 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs @@ -34,6 +34,16 @@ internal sealed class JsonApiSchemaGenerator : ISchemaGenerator typeof(NullableToOneRelationshipInRequest<>) }; + private static readonly string[] DocumentPropertyNamesInOrder = + { + JsonApiPropertyName.Jsonapi, + JsonApiPropertyName.Links, + JsonApiPropertyName.Data, + JsonApiPropertyName.Errors, + JsonApiPropertyName.Included, + JsonApiPropertyName.Meta + }; + private readonly ISchemaGenerator _defaultSchemaGenerator; private readonly ResourceObjectSchemaGenerator _resourceObjectSchemaGenerator; private readonly NullableReferenceSchemaGenerator _nullableReferenceSchemaGenerator; @@ -76,7 +86,7 @@ public OpenApiSchema GenerateSchema(Type modelType, SchemaRepository schemaRepos } } - return _defaultSchemaGenerator.GenerateSchema(modelType, schemaRepository, memberInfo, parameterInfo); + return _defaultSchemaGenerator.GenerateSchema(modelType, schemaRepository, memberInfo, parameterInfo, routeInfo); } private static bool IsJsonApiDocument(Type type) @@ -100,7 +110,9 @@ private OpenApiSchema GenerateJsonApiDocumentSchema(Type documentType) ? CreateArrayTypeDataSchema(referenceSchemaForResourceObject) : referenceSchemaForResourceObject; - fullSchemaForDocument.Properties[JsonApiObjectPropertyName.Data] = referenceSchemaForDataObject; + fullSchemaForDocument.Properties[JsonApiPropertyName.Data] = referenceSchemaForDataObject; + + fullSchemaForDocument.ReorderProperties(DocumentPropertyNamesInOrder); return referenceSchemaForDocument; } @@ -120,8 +132,8 @@ private static bool IsDataPropertyNullableInDocument(Type documentType) private void SetDataObjectSchemaToNullable(OpenApiSchema referenceSchemaForDocument) { OpenApiSchema fullSchemaForDocument = _schemaRepositoryAccessor.Current.Schemas[referenceSchemaForDocument.Reference.Id]; - OpenApiSchema referenceSchemaForData = fullSchemaForDocument.Properties[JsonApiObjectPropertyName.Data]; - fullSchemaForDocument.Properties[JsonApiObjectPropertyName.Data] = _nullableReferenceSchemaGenerator.GenerateSchema(referenceSchemaForData); + OpenApiSchema referenceSchemaForData = fullSchemaForDocument.Properties[JsonApiPropertyName.Data]; + fullSchemaForDocument.Properties[JsonApiPropertyName.Data] = _nullableReferenceSchemaGenerator.GenerateSchema(referenceSchemaForData); } private static OpenApiSchema CreateArrayTypeDataSchema(OpenApiSchema referenceSchemaForResourceObject) diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/OpenApiSchemaExtensions.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/OpenApiSchemaExtensions.cs new file mode 100644 index 0000000000..b54e16fd96 --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/OpenApiSchemaExtensions.cs @@ -0,0 +1,26 @@ +using Microsoft.OpenApi.Models; + +namespace JsonApiDotNetCore.OpenApi.SwaggerComponents; + +internal static class OpenApiSchemaExtensions +{ + public static void ReorderProperties(this OpenApiSchema fullSchemaForResourceObject, IEnumerable propertyNamesInOrder) + { + var propertiesInOrder = new Dictionary(); + + foreach (string propertyName in propertyNamesInOrder) + { + if (fullSchemaForResourceObject.Properties.TryGetValue(propertyName, out OpenApiSchema? schema)) + { + propertiesInOrder.Add(propertyName, schema); + } + } + + if (fullSchemaForResourceObject.Properties.Count != propertiesInOrder.Count) + { + throw new UnreachableCodeException(); + } + + fullSchemaForResourceObject.Properties = propertiesInOrder; + } +} diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs index 054c49d2ea..29b6d29a47 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs @@ -23,6 +23,13 @@ internal sealed class ResourceFieldObjectSchemaBuilder typeof(NullableToOneRelationshipInResponse<>) }; + private static readonly string[] RelationshipObjectPropertyNamesInOrder = + { + JsonApiPropertyName.Links, + JsonApiPropertyName.Data, + JsonApiPropertyName.Meta + }; + private readonly ResourceTypeInfo _resourceTypeInfo; private readonly ISchemaRepositoryAccessor _schemaRepositoryAccessor; private readonly SchemaGenerator _defaultSchemaGenerator; @@ -156,7 +163,7 @@ private void GenerateResourceIdentifierObjectSchema(Type resourceIdentifierObjec _schemaRepositoryAccessor.Current.Schemas[referenceSchemaForResourceIdentifierObject.Reference.Id]; Type resourceType = resourceIdentifierObjectType.GetGenericArguments()[0]; - fullSchemaForResourceIdentifierObject.Properties[JsonApiObjectPropertyName.Type] = _resourceTypeSchemaGenerator.Get(resourceType); + fullSchemaForResourceIdentifierObject.Properties[JsonApiPropertyName.Type] = _resourceTypeSchemaGenerator.Get(resourceType); } private void AddRelationshipSchemaToResourceObject(RelationshipAttribute relationship, OpenApiSchema fullSchemaForRelationshipsObject) @@ -194,13 +201,14 @@ private OpenApiSchema CreateRelationshipSchema(Type relationshipSchemaType) if (IsDataPropertyNullableInRelationshipSchemaType(relationshipSchemaType)) { - fullSchema.Properties[JsonApiObjectPropertyName.Data] = - _nullableReferenceSchemaGenerator.GenerateSchema(fullSchema.Properties[JsonApiObjectPropertyName.Data]); + fullSchema.Properties[JsonApiPropertyName.Data] = _nullableReferenceSchemaGenerator.GenerateSchema(fullSchema.Properties[JsonApiPropertyName.Data]); } if (IsRelationshipInResponseType(relationshipSchemaType)) { - fullSchema.Required.Remove(JsonApiObjectPropertyName.Data); + fullSchema.Required.Remove(JsonApiPropertyName.Data); + + fullSchema.ReorderProperties(RelationshipObjectPropertyNamesInOrder); } return referenceSchema; diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs index 4be66f8f8d..76d730801c 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs @@ -7,6 +7,16 @@ namespace JsonApiDotNetCore.OpenApi.SwaggerComponents; internal sealed class ResourceObjectSchemaGenerator { + private static readonly string[] ResourceObjectPropertyNamesInOrder = + { + JsonApiPropertyName.Type, + JsonApiPropertyName.Id, + JsonApiPropertyName.Attributes, + JsonApiPropertyName.Relationships, + JsonApiPropertyName.Links, + JsonApiPropertyName.Meta + }; + private readonly SchemaGenerator _defaultSchemaGenerator; private readonly IResourceGraph _resourceGraph; private readonly IJsonApiOptions _options; @@ -50,15 +60,7 @@ public OpenApiSchema GenerateSchema(Type resourceObjectType) SetResourceRelationships(fullSchemaForResourceObject, fieldObjectBuilder); - ReorderMembers(fullSchemaForResourceObject, new[] - { - JsonApiObjectPropertyName.Type, - JsonApiObjectPropertyName.Id, - JsonApiObjectPropertyName.AttributesObject, - JsonApiObjectPropertyName.RelationshipsObject, - JsonApiObjectPropertyName.LinksObject, - JsonApiObjectPropertyName.MetaObject - }); + fullSchemaForResourceObject.ReorderProperties(ResourceObjectPropertyNamesInOrder); return referenceSchemaForResourceObject; } @@ -83,31 +85,31 @@ private void RemoveResourceIdIfPostResourceObject(ResourceTypeInfo resourceTypeI if (clientIdGeneration == ClientIdGenerationMode.Forbidden) { - fullSchemaForResourceObject.Required.Remove(JsonApiObjectPropertyName.Id); - fullSchemaForResourceObject.Properties.Remove(JsonApiObjectPropertyName.Id); + fullSchemaForResourceObject.Required.Remove(JsonApiPropertyName.Id); + fullSchemaForResourceObject.Properties.Remove(JsonApiPropertyName.Id); } else if (clientIdGeneration == ClientIdGenerationMode.Allowed) { - fullSchemaForResourceObject.Required.Remove(JsonApiObjectPropertyName.Id); + fullSchemaForResourceObject.Required.Remove(JsonApiPropertyName.Id); } } } private void SetResourceType(OpenApiSchema fullSchemaForResourceObject, Type resourceType) { - fullSchemaForResourceObject.Properties[JsonApiObjectPropertyName.Type] = _resourceTypeSchemaGenerator.Get(resourceType); + fullSchemaForResourceObject.Properties[JsonApiPropertyName.Type] = _resourceTypeSchemaGenerator.Get(resourceType); } private void SetResourceAttributes(OpenApiSchema fullSchemaForResourceObject, ResourceFieldObjectSchemaBuilder builder) { - OpenApiSchema referenceSchemaForAttributesObject = fullSchemaForResourceObject.Properties[JsonApiObjectPropertyName.AttributesObject]; + OpenApiSchema referenceSchemaForAttributesObject = fullSchemaForResourceObject.Properties[JsonApiPropertyName.Attributes]; OpenApiSchema fullSchemaForAttributesObject = _schemaRepositoryAccessor.Current.Schemas[referenceSchemaForAttributesObject.Reference.Id]; builder.SetMembersOfAttributesObject(fullSchemaForAttributesObject); if (!fullSchemaForAttributesObject.Properties.Any()) { - fullSchemaForResourceObject.Properties.Remove(JsonApiObjectPropertyName.AttributesObject); + fullSchemaForResourceObject.Properties.Remove(JsonApiPropertyName.Attributes); _schemaRepositoryAccessor.Current.Schemas.Remove(referenceSchemaForAttributesObject.Reference.Id); } else @@ -118,14 +120,14 @@ private void SetResourceAttributes(OpenApiSchema fullSchemaForResourceObject, Re private void SetResourceRelationships(OpenApiSchema fullSchemaForResourceObject, ResourceFieldObjectSchemaBuilder builder) { - OpenApiSchema referenceSchemaForRelationshipsObject = fullSchemaForResourceObject.Properties[JsonApiObjectPropertyName.RelationshipsObject]; + OpenApiSchema referenceSchemaForRelationshipsObject = fullSchemaForResourceObject.Properties[JsonApiPropertyName.Relationships]; OpenApiSchema fullSchemaForRelationshipsObject = _schemaRepositoryAccessor.Current.Schemas[referenceSchemaForRelationshipsObject.Reference.Id]; builder.SetMembersOfRelationshipsObject(fullSchemaForRelationshipsObject); if (!fullSchemaForRelationshipsObject.Properties.Any()) { - fullSchemaForResourceObject.Properties.Remove(JsonApiObjectPropertyName.RelationshipsObject); + fullSchemaForResourceObject.Properties.Remove(JsonApiPropertyName.Relationships); _schemaRepositoryAccessor.Current.Schemas.Remove(referenceSchemaForRelationshipsObject.Reference.Id); } else @@ -133,19 +135,4 @@ private void SetResourceRelationships(OpenApiSchema fullSchemaForResourceObject, fullSchemaForRelationshipsObject.AdditionalPropertiesAllowed = false; } } - - private static void ReorderMembers(OpenApiSchema fullSchemaForResourceObject, IEnumerable orderedMembers) - { - var reorderedMembers = new Dictionary(); - - foreach (string member in orderedMembers) - { - if (fullSchemaForResourceObject.Properties.TryGetValue(member, out OpenApiSchema? schema)) - { - reorderedMembers[member] = schema; - } - } - - fullSchemaForResourceObject.Properties = reorderedMembers; - } } diff --git a/test/OpenApiClientTests/LegacyClient/swagger.g.json b/test/OpenApiClientTests/LegacyClient/swagger.g.json index d1e73c4747..83a045edbd 100644 --- a/test/OpenApiClientTests/LegacyClient/swagger.g.json +++ b/test/OpenApiClientTests/LegacyClient/swagger.g.json @@ -2019,6 +2019,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-collection-document" + }, "data": { "type": "array", "items": { @@ -2028,12 +2034,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" } }, "additionalProperties": false @@ -2141,18 +2141,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-document" + }, "data": { "$ref": "#/components/schemas/airplane-data-in-response" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-document" } }, "additionalProperties": false @@ -2276,6 +2276,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-collection-document" + }, "data": { "type": "array", "items": { @@ -2285,12 +2291,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" } }, "additionalProperties": false @@ -2391,6 +2391,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + }, "data": { "type": "array", "items": { @@ -2400,12 +2406,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" } }, "additionalProperties": false @@ -2417,18 +2417,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-identifier-document" + }, "data": { "$ref": "#/components/schemas/flight-attendant-identifier" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-document" } }, "additionalProperties": false @@ -2464,18 +2464,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-document" + }, "data": { "$ref": "#/components/schemas/flight-attendant-data-in-response" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-document" } }, "additionalProperties": false @@ -2529,18 +2529,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-document" + }, "data": { "$ref": "#/components/schemas/flight-attendant-data-in-response" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-document" } }, "additionalProperties": false @@ -2608,6 +2608,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-collection-document" + }, "data": { "type": "array", "items": { @@ -2617,12 +2623,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" } }, "additionalProperties": false @@ -2720,6 +2720,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + }, "data": { "type": "array", "items": { @@ -2729,12 +2735,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" } }, "additionalProperties": false @@ -2770,18 +2770,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-document" + }, "data": { "$ref": "#/components/schemas/flight-data-in-response" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-document" } }, "additionalProperties": false @@ -2953,13 +2953,13 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" }, + "describedby": { + "type": "string" + }, "first": { "minLength": 1, "type": "string" @@ -2987,12 +2987,12 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" + }, + "describedby": { + "type": "string" } }, "additionalProperties": false @@ -3040,6 +3040,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-identifier-document" + }, "data": { "oneOf": [ { @@ -3053,12 +3059,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-document" } }, "additionalProperties": false @@ -3070,6 +3070,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-document" + }, "data": { "oneOf": [ { @@ -3083,12 +3089,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-document" } }, "additionalProperties": false @@ -3118,6 +3118,9 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/links-in-relationship-object" + }, "data": { "oneOf": [ { @@ -3128,9 +3131,6 @@ } ] }, - "links": { - "$ref": "#/components/schemas/links-in-relationship-object" - }, "meta": { "type": "object", "additionalProperties": { } @@ -3158,6 +3158,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-collection-document" + }, "data": { "type": "array", "items": { @@ -3167,12 +3173,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" } }, "additionalProperties": false @@ -3229,6 +3229,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + }, "data": { "type": "array", "items": { @@ -3238,12 +3244,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" } }, "additionalProperties": false @@ -3275,15 +3275,15 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/links-in-relationship-object" + }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/flight-attendant-identifier" } }, - "links": { - "$ref": "#/components/schemas/links-in-relationship-object" - }, "meta": { "type": "object", "additionalProperties": { } @@ -3312,15 +3312,15 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/links-in-relationship-object" + }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/flight-identifier" } }, - "links": { - "$ref": "#/components/schemas/links-in-relationship-object" - }, "meta": { "type": "object", "additionalProperties": { } @@ -3349,15 +3349,15 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/links-in-relationship-object" + }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/passenger-identifier" } }, - "links": { - "$ref": "#/components/schemas/links-in-relationship-object" - }, "meta": { "type": "object", "additionalProperties": { } @@ -3383,12 +3383,12 @@ ], "type": "object", "properties": { - "data": { - "$ref": "#/components/schemas/flight-attendant-identifier" - }, "links": { "$ref": "#/components/schemas/links-in-relationship-object" }, + "data": { + "$ref": "#/components/schemas/flight-attendant-identifier" + }, "meta": { "type": "object", "additionalProperties": { } diff --git a/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json b/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json index 5d2569050d..a477f7a7fb 100644 --- a/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json +++ b/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json @@ -815,13 +815,13 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" }, + "describedby": { + "type": "string" + }, "first": { "minLength": 1, "type": "string" @@ -849,12 +849,12 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" + }, + "describedby": { + "type": "string" } }, "additionalProperties": false @@ -902,6 +902,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + }, "data": { "oneOf": [ { @@ -915,12 +921,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" } }, "additionalProperties": false @@ -932,6 +932,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "oneOf": [ { @@ -945,12 +951,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -980,6 +980,9 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/linksInRelationshipObject" + }, "data": { "oneOf": [ { @@ -990,9 +993,6 @@ } ] }, - "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" - }, "meta": { "type": "object", "additionalProperties": { } @@ -1023,6 +1023,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1032,12 +1038,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" } }, "additionalProperties": false @@ -1094,6 +1094,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1103,12 +1109,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" } }, "additionalProperties": false @@ -1120,18 +1120,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + }, "data": { "$ref": "#/components/schemas/staffMemberIdentifier" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" } }, "additionalProperties": false @@ -1149,18 +1149,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "$ref": "#/components/schemas/staffMemberDataInResponse" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -1214,6 +1214,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1223,12 +1229,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" } }, "additionalProperties": false @@ -1336,18 +1336,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "$ref": "#/components/schemas/supermarketDataInResponse" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -1438,15 +1438,15 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/linksInRelationshipObject" + }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/staffMemberIdentifier" } }, - "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" - }, "meta": { "type": "object", "additionalProperties": { } @@ -1472,12 +1472,12 @@ ], "type": "object", "properties": { - "data": { - "$ref": "#/components/schemas/staffMemberIdentifier" - }, "links": { "$ref": "#/components/schemas/linksInRelationshipObject" }, + "data": { + "$ref": "#/components/schemas/staffMemberIdentifier" + }, "meta": { "type": "object", "additionalProperties": { } diff --git a/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json b/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json index 9d7656c612..b818a08717 100644 --- a/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json +++ b/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json @@ -815,13 +815,13 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" }, + "describedby": { + "type": "string" + }, "first": { "minLength": 1, "type": "string" @@ -849,12 +849,12 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" + }, + "describedby": { + "type": "string" } }, "additionalProperties": false @@ -902,6 +902,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-identifier-document" + }, "data": { "oneOf": [ { @@ -915,12 +921,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-document" } }, "additionalProperties": false @@ -932,6 +932,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-document" + }, "data": { "oneOf": [ { @@ -945,12 +951,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-document" } }, "additionalProperties": false @@ -980,6 +980,9 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/links-in-relationship-object" + }, "data": { "oneOf": [ { @@ -990,9 +993,6 @@ } ] }, - "links": { - "$ref": "#/components/schemas/links-in-relationship-object" - }, "meta": { "type": "object", "additionalProperties": { } @@ -1023,6 +1023,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-collection-document" + }, "data": { "type": "array", "items": { @@ -1032,12 +1038,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" } }, "additionalProperties": false @@ -1094,6 +1094,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + }, "data": { "type": "array", "items": { @@ -1103,12 +1109,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" } }, "additionalProperties": false @@ -1120,18 +1120,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-identifier-document" + }, "data": { "$ref": "#/components/schemas/staff-member-identifier" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-document" } }, "additionalProperties": false @@ -1149,18 +1149,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-document" + }, "data": { "$ref": "#/components/schemas/staff-member-data-in-response" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-document" } }, "additionalProperties": false @@ -1214,6 +1214,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-collection-document" + }, "data": { "type": "array", "items": { @@ -1223,12 +1229,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" } }, "additionalProperties": false @@ -1336,18 +1336,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-document" + }, "data": { "$ref": "#/components/schemas/supermarket-data-in-response" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-document" } }, "additionalProperties": false @@ -1438,15 +1438,15 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/links-in-relationship-object" + }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/staff-member-identifier" } }, - "links": { - "$ref": "#/components/schemas/links-in-relationship-object" - }, "meta": { "type": "object", "additionalProperties": { } @@ -1472,12 +1472,12 @@ ], "type": "object", "properties": { - "data": { - "$ref": "#/components/schemas/staff-member-identifier" - }, "links": { "$ref": "#/components/schemas/links-in-relationship-object" }, + "data": { + "$ref": "#/components/schemas/staff-member-identifier" + }, "meta": { "type": "object", "additionalProperties": { } diff --git a/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json b/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json index ae79e8470b..80c5fedf0c 100644 --- a/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json +++ b/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json @@ -815,13 +815,13 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" }, + "describedby": { + "type": "string" + }, "first": { "minLength": 1, "type": "string" @@ -849,12 +849,12 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" + }, + "describedby": { + "type": "string" } }, "additionalProperties": false @@ -902,6 +902,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/JsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/LinksInResourceIdentifierDocument" + }, "data": { "oneOf": [ { @@ -915,12 +921,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/LinksInResourceIdentifierDocument" } }, "additionalProperties": false @@ -932,6 +932,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/JsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/LinksInResourceDocument" + }, "data": { "oneOf": [ { @@ -945,12 +951,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/LinksInResourceDocument" } }, "additionalProperties": false @@ -980,6 +980,9 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/LinksInRelationshipObject" + }, "data": { "oneOf": [ { @@ -990,9 +993,6 @@ } ] }, - "links": { - "$ref": "#/components/schemas/LinksInRelationshipObject" - }, "meta": { "type": "object", "additionalProperties": { } @@ -1023,6 +1023,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/JsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/LinksInResourceCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1032,12 +1038,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/LinksInResourceCollectionDocument" } }, "additionalProperties": false @@ -1094,6 +1094,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/JsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/LinksInResourceIdentifierCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1103,12 +1109,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/LinksInResourceIdentifierCollectionDocument" } }, "additionalProperties": false @@ -1120,18 +1120,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/JsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/LinksInResourceIdentifierDocument" + }, "data": { "$ref": "#/components/schemas/StaffMemberIdentifier" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/LinksInResourceIdentifierDocument" } }, "additionalProperties": false @@ -1149,18 +1149,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/JsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/LinksInResourceDocument" + }, "data": { "$ref": "#/components/schemas/StaffMemberDataInResponse" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/LinksInResourceDocument" } }, "additionalProperties": false @@ -1214,6 +1214,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/JsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/LinksInResourceCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1223,12 +1229,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/LinksInResourceCollectionDocument" } }, "additionalProperties": false @@ -1336,18 +1336,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/JsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/LinksInResourceDocument" + }, "data": { "$ref": "#/components/schemas/SupermarketDataInResponse" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/JsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/LinksInResourceDocument" } }, "additionalProperties": false @@ -1438,15 +1438,15 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/LinksInRelationshipObject" + }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/StaffMemberIdentifier" } }, - "links": { - "$ref": "#/components/schemas/LinksInRelationshipObject" - }, "meta": { "type": "object", "additionalProperties": { } @@ -1472,12 +1472,12 @@ ], "type": "object", "properties": { - "data": { - "$ref": "#/components/schemas/StaffMemberIdentifier" - }, "links": { "$ref": "#/components/schemas/LinksInRelationshipObject" }, + "data": { + "$ref": "#/components/schemas/StaffMemberIdentifier" + }, "meta": { "type": "object", "additionalProperties": { } diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json index c0b2808012..e880abd174 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json @@ -934,6 +934,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + }, "data": { "type": "array", "items": { @@ -943,12 +949,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" } }, "additionalProperties": false @@ -1002,6 +1002,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1011,12 +1017,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" } }, "additionalProperties": false @@ -1128,13 +1128,13 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" }, + "describedby": { + "type": "string" + }, "first": { "minLength": 1, "type": "string" @@ -1162,12 +1162,12 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" + }, + "describedby": { + "type": "string" } }, "additionalProperties": false @@ -1215,6 +1215,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + }, "data": { "oneOf": [ { @@ -1228,12 +1234,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" } }, "additionalProperties": false @@ -1245,6 +1245,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "oneOf": [ { @@ -1258,12 +1264,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -1293,6 +1293,9 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/linksInRelationshipObject" + }, "data": { "oneOf": [ { @@ -1303,9 +1306,6 @@ } ] }, - "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" - }, "meta": { "type": "object", "additionalProperties": { } @@ -1429,6 +1429,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1438,12 +1444,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" } }, "additionalProperties": false @@ -1551,18 +1551,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "$ref": "#/components/schemas/resourceDataInResponse" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -1656,15 +1656,15 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/linksInRelationshipObject" + }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/emptyIdentifier" } }, - "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" - }, "meta": { "type": "object", "additionalProperties": { } diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json index cbf832157e..989dded857 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json @@ -934,6 +934,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + }, "data": { "type": "array", "items": { @@ -943,12 +949,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" } }, "additionalProperties": false @@ -1002,6 +1002,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1011,12 +1017,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" } }, "additionalProperties": false @@ -1028,18 +1028,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + }, "data": { "$ref": "#/components/schemas/emptyIdentifier" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" } }, "additionalProperties": false @@ -1057,18 +1057,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "$ref": "#/components/schemas/emptyDataInResponse" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -1174,13 +1174,13 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" }, + "describedby": { + "type": "string" + }, "first": { "minLength": 1, "type": "string" @@ -1208,12 +1208,12 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" + }, + "describedby": { + "type": "string" } }, "additionalProperties": false @@ -1261,6 +1261,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + }, "data": { "oneOf": [ { @@ -1274,12 +1280,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" } }, "additionalProperties": false @@ -1291,6 +1291,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "oneOf": [ { @@ -1304,12 +1310,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -1339,6 +1339,9 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/linksInRelationshipObject" + }, "data": { "oneOf": [ { @@ -1349,9 +1352,6 @@ } ] }, - "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" - }, "meta": { "type": "object", "additionalProperties": { } @@ -1467,6 +1467,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1476,12 +1482,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" } }, "additionalProperties": false @@ -1589,18 +1589,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "$ref": "#/components/schemas/resourceDataInResponse" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -1692,15 +1692,15 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/linksInRelationshipObject" + }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/emptyIdentifier" } }, - "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" - }, "meta": { "type": "object", "additionalProperties": { } @@ -1726,12 +1726,12 @@ ], "type": "object", "properties": { - "data": { - "$ref": "#/components/schemas/emptyIdentifier" - }, "links": { "$ref": "#/components/schemas/linksInRelationshipObject" }, + "data": { + "$ref": "#/components/schemas/emptyIdentifier" + }, "meta": { "type": "object", "additionalProperties": { } diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json index 76623a9819..762ba9f438 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json @@ -1236,6 +1236,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1245,12 +1251,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" } }, "additionalProperties": false @@ -1304,6 +1304,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1313,12 +1319,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" } }, "additionalProperties": false @@ -1330,18 +1330,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + }, "data": { "$ref": "#/components/schemas/emptyIdentifier" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" } }, "additionalProperties": false @@ -1359,18 +1359,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "$ref": "#/components/schemas/emptyDataInResponse" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -1476,13 +1476,13 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" }, + "describedby": { + "type": "string" + }, "first": { "minLength": 1, "type": "string" @@ -1510,12 +1510,12 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" + }, + "describedby": { + "type": "string" } }, "additionalProperties": false @@ -1563,6 +1563,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + }, "data": { "oneOf": [ { @@ -1576,12 +1582,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" } }, "additionalProperties": false @@ -1593,6 +1593,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "oneOf": [ { @@ -1606,12 +1612,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -1641,6 +1641,9 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/linksInRelationshipObject" + }, "data": { "oneOf": [ { @@ -1651,9 +1654,6 @@ } ] }, - "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" - }, "meta": { "type": "object", "additionalProperties": { } @@ -1800,6 +1800,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1809,12 +1815,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" } }, "additionalProperties": false @@ -1922,18 +1922,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "$ref": "#/components/schemas/resourceDataInResponse" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -2047,15 +2047,15 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/linksInRelationshipObject" + }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/emptyIdentifier" } }, - "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" - }, "meta": { "type": "object", "additionalProperties": { } @@ -2081,12 +2081,12 @@ ], "type": "object", "properties": { - "data": { - "$ref": "#/components/schemas/emptyIdentifier" - }, "links": { "$ref": "#/components/schemas/linksInRelationshipObject" }, + "data": { + "$ref": "#/components/schemas/emptyIdentifier" + }, "meta": { "type": "object", "additionalProperties": { } diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json index 73f9c6048a..9ef5d3892f 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json @@ -1236,6 +1236,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1245,12 +1251,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" } }, "additionalProperties": false @@ -1304,6 +1304,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1313,12 +1319,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" } }, "additionalProperties": false @@ -1330,18 +1330,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + }, "data": { "$ref": "#/components/schemas/emptyIdentifier" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" } }, "additionalProperties": false @@ -1359,18 +1359,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "$ref": "#/components/schemas/emptyDataInResponse" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -1476,13 +1476,13 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" }, + "describedby": { + "type": "string" + }, "first": { "minLength": 1, "type": "string" @@ -1510,12 +1510,12 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" + }, + "describedby": { + "type": "string" } }, "additionalProperties": false @@ -1563,6 +1563,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceIdentifierDocument" + }, "data": { "oneOf": [ { @@ -1576,12 +1582,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" } }, "additionalProperties": false @@ -1593,6 +1593,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "oneOf": [ { @@ -1606,12 +1612,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -1641,6 +1641,9 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/linksInRelationshipObject" + }, "data": { "oneOf": [ { @@ -1651,9 +1654,6 @@ } ] }, - "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" - }, "meta": { "type": "object", "additionalProperties": { } @@ -1794,6 +1794,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceCollectionDocument" + }, "data": { "type": "array", "items": { @@ -1803,12 +1809,6 @@ "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" } }, "additionalProperties": false @@ -1916,18 +1916,18 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapiObject" + }, + "links": { + "$ref": "#/components/schemas/linksInResourceDocument" + }, "data": { "$ref": "#/components/schemas/resourceDataInResponse" }, "meta": { "type": "object", "additionalProperties": { } - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapiObject" - }, - "links": { - "$ref": "#/components/schemas/linksInResourceDocument" } }, "additionalProperties": false @@ -2041,15 +2041,15 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/linksInRelationshipObject" + }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/emptyIdentifier" } }, - "links": { - "$ref": "#/components/schemas/linksInRelationshipObject" - }, "meta": { "type": "object", "additionalProperties": { } @@ -2075,12 +2075,12 @@ ], "type": "object", "properties": { - "data": { - "$ref": "#/components/schemas/emptyIdentifier" - }, "links": { "$ref": "#/components/schemas/linksInRelationshipObject" }, + "data": { + "$ref": "#/components/schemas/emptyIdentifier" + }, "meta": { "type": "object", "additionalProperties": { } diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json b/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json index 3809d15c91..83a045edbd 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json +++ b/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json @@ -2019,6 +2019,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-collection-document" + }, "data": { "type": "array", "items": { @@ -2027,13 +2033,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "additionalProperties": { } } }, "additionalProperties": false @@ -2105,7 +2105,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} + "additionalProperties": { } } }, "additionalProperties": false @@ -2141,18 +2141,18 @@ ], "type": "object", "properties": { - "data": { - "$ref": "#/components/schemas/airplane-data-in-response" - }, - "meta": { - "type": "object", - "additionalProperties": {} - }, "jsonapi": { "$ref": "#/components/schemas/jsonapi-object" }, "links": { "$ref": "#/components/schemas/links-in-resource-document" + }, + "data": { + "$ref": "#/components/schemas/airplane-data-in-response" + }, + "meta": { + "type": "object", + "additionalProperties": { } } }, "additionalProperties": false @@ -2276,6 +2276,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-collection-document" + }, "data": { "type": "array", "items": { @@ -2284,13 +2290,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "additionalProperties": { } } }, "additionalProperties": false @@ -2362,7 +2362,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} + "additionalProperties": { } } }, "additionalProperties": false @@ -2391,6 +2391,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + }, "data": { "type": "array", "items": { @@ -2399,13 +2405,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + "additionalProperties": { } } }, "additionalProperties": false @@ -2417,18 +2417,18 @@ ], "type": "object", "properties": { - "data": { - "$ref": "#/components/schemas/flight-attendant-identifier" - }, - "meta": { - "type": "object", - "additionalProperties": {} - }, "jsonapi": { "$ref": "#/components/schemas/jsonapi-object" }, "links": { "$ref": "#/components/schemas/links-in-resource-identifier-document" + }, + "data": { + "$ref": "#/components/schemas/flight-attendant-identifier" + }, + "meta": { + "type": "object", + "additionalProperties": { } } }, "additionalProperties": false @@ -2464,18 +2464,18 @@ ], "type": "object", "properties": { - "data": { - "$ref": "#/components/schemas/flight-attendant-data-in-response" - }, - "meta": { - "type": "object", - "additionalProperties": {} - }, "jsonapi": { "$ref": "#/components/schemas/jsonapi-object" }, "links": { "$ref": "#/components/schemas/links-in-resource-document" + }, + "data": { + "$ref": "#/components/schemas/flight-attendant-data-in-response" + }, + "meta": { + "type": "object", + "additionalProperties": { } } }, "additionalProperties": false @@ -2529,18 +2529,18 @@ ], "type": "object", "properties": { - "data": { - "$ref": "#/components/schemas/flight-attendant-data-in-response" - }, - "meta": { - "type": "object", - "additionalProperties": {} - }, "jsonapi": { "$ref": "#/components/schemas/jsonapi-object" }, "links": { "$ref": "#/components/schemas/links-in-resource-document" + }, + "data": { + "$ref": "#/components/schemas/flight-attendant-data-in-response" + }, + "meta": { + "type": "object", + "additionalProperties": { } } }, "additionalProperties": false @@ -2608,6 +2608,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-collection-document" + }, "data": { "type": "array", "items": { @@ -2616,13 +2622,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "additionalProperties": { } } }, "additionalProperties": false @@ -2691,7 +2691,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} + "additionalProperties": { } } }, "additionalProperties": false @@ -2720,6 +2720,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + }, "data": { "type": "array", "items": { @@ -2728,13 +2734,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + "additionalProperties": { } } }, "additionalProperties": false @@ -2770,18 +2770,18 @@ ], "type": "object", "properties": { - "data": { - "$ref": "#/components/schemas/flight-data-in-response" - }, - "meta": { - "type": "object", - "additionalProperties": {} - }, "jsonapi": { "$ref": "#/components/schemas/jsonapi-object" }, "links": { "$ref": "#/components/schemas/links-in-resource-document" + }, + "data": { + "$ref": "#/components/schemas/flight-data-in-response" + }, + "meta": { + "type": "object", + "additionalProperties": { } } }, "additionalProperties": false @@ -2872,7 +2872,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} + "additionalProperties": { } } }, "additionalProperties": false @@ -2953,13 +2953,13 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" }, + "describedby": { + "type": "string" + }, "first": { "minLength": 1, "type": "string" @@ -2987,12 +2987,12 @@ "minLength": 1, "type": "string" }, - "describedby": { - "type": "string" - }, "related": { "minLength": 1, "type": "string" + }, + "describedby": { + "type": "string" } }, "additionalProperties": false @@ -3029,7 +3029,7 @@ "type": "array" } ], - "items": {} + "items": { } }, "nullable": true }, @@ -3040,6 +3040,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-identifier-document" + }, "data": { "oneOf": [ { @@ -3052,13 +3058,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-document" + "additionalProperties": { } } }, "additionalProperties": false @@ -3070,6 +3070,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-document" + }, "data": { "oneOf": [ { @@ -3082,13 +3088,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-document" + "additionalProperties": { } } }, "additionalProperties": false @@ -3118,6 +3118,9 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/links-in-relationship-object" + }, "data": { "oneOf": [ { @@ -3128,12 +3131,9 @@ } ] }, - "links": { - "$ref": "#/components/schemas/links-in-relationship-object" - }, "meta": { "type": "object", - "additionalProperties": {} + "additionalProperties": { } } }, "additionalProperties": false @@ -3158,6 +3158,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-collection-document" + }, "data": { "type": "array", "items": { @@ -3166,13 +3172,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-collection-document" + "additionalProperties": { } } }, "additionalProperties": false @@ -3200,7 +3200,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} + "additionalProperties": { } } }, "additionalProperties": false @@ -3229,6 +3229,12 @@ ], "type": "object", "properties": { + "jsonapi": { + "$ref": "#/components/schemas/jsonapi-object" + }, + "links": { + "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + }, "data": { "type": "array", "items": { @@ -3237,13 +3243,7 @@ }, "meta": { "type": "object", - "additionalProperties": {} - }, - "jsonapi": { - "$ref": "#/components/schemas/jsonapi-object" - }, - "links": { - "$ref": "#/components/schemas/links-in-resource-identifier-collection-document" + "additionalProperties": { } } }, "additionalProperties": false @@ -3275,18 +3275,18 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/links-in-relationship-object" + }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/flight-attendant-identifier" } }, - "links": { - "$ref": "#/components/schemas/links-in-relationship-object" - }, "meta": { "type": "object", - "additionalProperties": {} + "additionalProperties": { } } }, "additionalProperties": false @@ -3312,18 +3312,18 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/links-in-relationship-object" + }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/flight-identifier" } }, - "links": { - "$ref": "#/components/schemas/links-in-relationship-object" - }, "meta": { "type": "object", - "additionalProperties": {} + "additionalProperties": { } } }, "additionalProperties": false @@ -3349,18 +3349,18 @@ ], "type": "object", "properties": { + "links": { + "$ref": "#/components/schemas/links-in-relationship-object" + }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/passenger-identifier" } }, - "links": { - "$ref": "#/components/schemas/links-in-relationship-object" - }, "meta": { "type": "object", - "additionalProperties": {} + "additionalProperties": { } } }, "additionalProperties": false @@ -3383,19 +3383,19 @@ ], "type": "object", "properties": { - "data": { - "$ref": "#/components/schemas/flight-attendant-identifier" - }, "links": { "$ref": "#/components/schemas/links-in-relationship-object" }, + "data": { + "$ref": "#/components/schemas/flight-attendant-identifier" + }, "meta": { "type": "object", - "additionalProperties": {} + "additionalProperties": { } } }, "additionalProperties": false } } } -} +} \ No newline at end of file