From 29a0d46288929df3ae8797b65cdf0a35c26d5481 Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Tue, 27 Feb 2024 10:26:50 +0000 Subject: [PATCH] Sort array-based ref-resolvable schema by array order. (#297) * Stabilise the ordering of the property generation for allOf, dependencies and dependentSchemas. * Fixed typos. --- .../JsonSchemaHelpers.Draft201909.cs | 12 ++++++------ .../JsonSchemaHelpers.Draft202012.cs | 12 ++++++------ .../JsonSchemaHelpers.Draft6.cs | 8 ++++---- .../JsonSchemaHelpers.Draft7.cs | 8 ++++---- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Solutions/Corvus.Json.CodeGeneration.201909/Corvus.Json.CodeGeneration.Draft201909/JsonSchemaHelpers.Draft201909.cs b/Solutions/Corvus.Json.CodeGeneration.201909/Corvus.Json.CodeGeneration.Draft201909/JsonSchemaHelpers.Draft201909.cs index f6d69eb59..2639e343d 100644 --- a/Solutions/Corvus.Json.CodeGeneration.201909/Corvus.Json.CodeGeneration.Draft201909/JsonSchemaHelpers.Draft201909.cs +++ b/Solutions/Corvus.Json.CodeGeneration.201909/Corvus.Json.CodeGeneration.Draft201909/JsonSchemaHelpers.Draft201909.cs @@ -325,7 +325,7 @@ private static Predicate CreateDraft201909IsExplicitArrayType() } /// - /// Creates the predicate that determiens whether this schema represents a simple type. + /// Creates the predicate that determines whether this schema represents a simple type. /// /// A predicate that returns if the schema is a simple type. private static Predicate CreateDraft201909IsSimpleType() @@ -399,7 +399,7 @@ private static Action k.Key.StartsWith("#/allOf")).Select(k => k.Value)) + foreach (TypeDeclaration allOfTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => k.Key.StartsWith("#/allOf")).OrderBy(k => k.Key).Select(k => k.Value)) { builder.FindAndBuildProperties(allOfTypeDeclaration, target, typesVisited, treatRequiredAsOptional); } @@ -417,17 +417,17 @@ private static Action k.Key.StartsWith("#/dependentSchemas")).Select(k => k.Value)) + foreach (TypeDeclaration dependentTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => k.Key.StartsWith("#/dependentSchemas")).OrderBy(k => k.Key).Select(k => k.Value)) { - builder.FindAndBuildProperties(dependentypeDeclaration, target, typesVisited, true); + builder.FindAndBuildProperties(dependentTypeDeclaration, target, typesVisited, true); } } if (schema.Dependencies.IsNotUndefined()) { - foreach (TypeDeclaration dependentypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => k.Key.StartsWith("#/dependencies")).Select(k => k.Value)) + foreach (TypeDeclaration dependentTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => k.Key.StartsWith("#/dependencies")).OrderBy(k => k.Key).Select(k => k.Value)) { - builder.FindAndBuildProperties(dependentypeDeclaration, target, typesVisited, true); + builder.FindAndBuildProperties(dependentTypeDeclaration, target, typesVisited, true); } } diff --git a/Solutions/Corvus.Json.CodeGeneration.202012/Corvus.Json.CodeGeneration.Draft202012/JsonSchemaHelpers.Draft202012.cs b/Solutions/Corvus.Json.CodeGeneration.202012/Corvus.Json.CodeGeneration.Draft202012/JsonSchemaHelpers.Draft202012.cs index 57508bfb4..b08f3691b 100644 --- a/Solutions/Corvus.Json.CodeGeneration.202012/Corvus.Json.CodeGeneration.Draft202012/JsonSchemaHelpers.Draft202012.cs +++ b/Solutions/Corvus.Json.CodeGeneration.202012/Corvus.Json.CodeGeneration.Draft202012/JsonSchemaHelpers.Draft202012.cs @@ -310,7 +310,7 @@ private static Predicate CreateDraft202012IsExplicitArrayType() } /// - /// Creates the predicate that determiens whether this Schema() represents a simple type. + /// Creates the predicate that determines whether this Schema() represents a simple type. /// /// if the Schema() is a simple type. private static Predicate CreateDraft202012IsSimpleType() @@ -384,7 +384,7 @@ private static Action k.Key.StartsWith("#/allOf")).Select(k => k.Value)) + foreach (TypeDeclaration allOfTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => k.Key.StartsWith("#/allOf")).OrderBy(k => k.Key).Select(k => k.Value)) { builder.FindAndBuildProperties(allOfTypeDeclaration, target, typesVisited, treatRequiredAsOptional); } @@ -402,17 +402,17 @@ private static Action k.Key.StartsWith("#/dependentSchemas")).Select(k => k.Value)) + foreach (TypeDeclaration dependentTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => k.Key.StartsWith("#/dependentSchemas")).OrderBy(k => k.Key).Select(k => k.Value)) { - builder.FindAndBuildProperties(dependentypeDeclaration, target, typesVisited, true); + builder.FindAndBuildProperties(dependentTypeDeclaration, target, typesVisited, true); } } if (schema.Dependencies.IsNotUndefined()) { - foreach (TypeDeclaration dependentypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => k.Key.StartsWith("#/dependencies")).Select(k => k.Value)) + foreach (TypeDeclaration dependentTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => k.Key.StartsWith("#/dependencies")).OrderBy(k => k.Key).Select(k => k.Value)) { - builder.FindAndBuildProperties(dependentypeDeclaration, target, typesVisited, true); + builder.FindAndBuildProperties(dependentTypeDeclaration, target, typesVisited, true); } } diff --git a/Solutions/Corvus.Json.CodeGeneration.6/Corvus.Json.CodeGeneration.Draft6/JsonSchemaHelpers.Draft6.cs b/Solutions/Corvus.Json.CodeGeneration.6/Corvus.Json.CodeGeneration.Draft6/JsonSchemaHelpers.Draft6.cs index 71b135d49..071cac7c6 100644 --- a/Solutions/Corvus.Json.CodeGeneration.6/Corvus.Json.CodeGeneration.Draft6/JsonSchemaHelpers.Draft6.cs +++ b/Solutions/Corvus.Json.CodeGeneration.6/Corvus.Json.CodeGeneration.Draft6/JsonSchemaHelpers.Draft6.cs @@ -274,7 +274,7 @@ private static Predicate CreateDraft6IsExplicitArrayType() } /// - /// Creates the predicate that determiens whether this schema represents a simple type. + /// Creates the predicate that determines whether this schema represents a simple type. /// /// if the schema is a simple type. private static Predicate CreateDraft6IsSimpleType() @@ -348,7 +348,7 @@ private static Action k.Key.StartsWith("#/allOf")).Select(k => k.Value)) + foreach (TypeDeclaration allOfTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => k.Key.StartsWith("#/allOf")).OrderBy(k => k.Key).Select(k => k.Value)) { builder.FindAndBuildProperties(allOfTypeDeclaration, target, typesVisited, treatRequiredAsOptional); } @@ -356,9 +356,9 @@ private static Action k.Key.StartsWith("#/dependencies")).Select(k => k.Value)) + foreach (TypeDeclaration dependentTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => k.Key.StartsWith("#/dependencies")).OrderBy(k => k.Key).Select(k => k.Value)) { - builder.FindAndBuildProperties(dependentypeDeclaration, target, typesVisited, true); + builder.FindAndBuildProperties(dependentTypeDeclaration, target, typesVisited, true); } } diff --git a/Solutions/Corvus.Json.CodeGeneration.7/Corvus.Json.CodeGeneration.Draft7/JsonSchemaHelpers.Draft7.cs b/Solutions/Corvus.Json.CodeGeneration.7/Corvus.Json.CodeGeneration.Draft7/JsonSchemaHelpers.Draft7.cs index 3f74a51e9..1576d4e2d 100644 --- a/Solutions/Corvus.Json.CodeGeneration.7/Corvus.Json.CodeGeneration.Draft7/JsonSchemaHelpers.Draft7.cs +++ b/Solutions/Corvus.Json.CodeGeneration.7/Corvus.Json.CodeGeneration.Draft7/JsonSchemaHelpers.Draft7.cs @@ -277,7 +277,7 @@ private static Predicate CreateDraft7IsExplicitArrayType() } /// - /// Creates the predicate that determiens whether this schema represents a simple type. + /// Creates the predicate that determines whether this schema represents a simple type. /// /// if the schema is a simple type. private static Predicate CreateDraft7IsSimpleType() @@ -351,7 +351,7 @@ private static Action k.Key.StartsWith("#/allOf")).Select(k => k.Value)) + foreach (TypeDeclaration allOfTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => k.Key.StartsWith("#/allOf")).OrderBy(k => k.Key).Select(k => k.Value)) { builder.FindAndBuildProperties(allOfTypeDeclaration, target, typesVisited, treatRequiredAsOptional); } @@ -369,9 +369,9 @@ private static Action k.Key.StartsWith("#/dependencies")).Select(k => k.Value)) + foreach (TypeDeclaration dependentTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => k.Key.StartsWith("#/dependencies")).OrderBy(k => k.Key).Select(k => k.Value)) { - builder.FindAndBuildProperties(dependentypeDeclaration, target, typesVisited, true); + builder.FindAndBuildProperties(dependentTypeDeclaration, target, typesVisited, true); } }