Skip to content

Commit

Permalink
Sort array-based ref-resolvable schema by array order. (#297)
Browse files Browse the repository at this point in the history
* Stabilise the ordering of the property generation for allOf, dependencies and dependentSchemas.

* Fixed typos.
  • Loading branch information
mwadams authored Feb 27, 2024
1 parent cdc8c24 commit 29a0d46
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ private static Predicate<JsonAny> CreateDraft201909IsExplicitArrayType()
}

/// <summary>
/// Creates the predicate that determiens whether this schema represents a simple type.
/// Creates the predicate that determines whether this schema represents a simple type.
/// </summary>
/// <returns>A predicate that returns <see langword="true"/> if the schema is a simple type.</returns>
private static Predicate<JsonAny> CreateDraft201909IsSimpleType()
Expand Down Expand Up @@ -399,7 +399,7 @@ private static Action<IPropertyBuilder, TypeDeclaration, TypeDeclaration, HashSe
if (schema.AllOf.IsNotUndefined())
{
foreach (TypeDeclaration allOfTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => 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);
}
Expand All @@ -417,17 +417,17 @@ private static Action<IPropertyBuilder, TypeDeclaration, TypeDeclaration, HashSe
if (schema.DependentSchemas.IsNotUndefined())
{
foreach (TypeDeclaration dependentypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ private static Predicate<JsonAny> CreateDraft202012IsExplicitArrayType()
}

/// <summary>
/// Creates the predicate that determiens whether this Schema() represents a simple type.
/// Creates the predicate that determines whether this Schema() represents a simple type.
/// </summary>
/// <returns><see langword="true"/> if the Schema() is a simple type.</returns>
private static Predicate<JsonAny> CreateDraft202012IsSimpleType()
Expand Down Expand Up @@ -384,7 +384,7 @@ private static Action<IPropertyBuilder, TypeDeclaration, TypeDeclaration, HashSe
if (schema.AllOf.IsNotUndefined())
{
foreach (TypeDeclaration allOfTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => 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);
}
Expand All @@ -402,17 +402,17 @@ private static Action<IPropertyBuilder, TypeDeclaration, TypeDeclaration, HashSe
if (schema.DependentSchemas.IsNotUndefined())
{
foreach (TypeDeclaration dependentypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private static Predicate<JsonAny> CreateDraft6IsExplicitArrayType()
}

/// <summary>
/// Creates the predicate that determiens whether this schema represents a simple type.
/// Creates the predicate that determines whether this schema represents a simple type.
/// </summary>
/// <returns><see langword="true"/> if the schema is a simple type.</returns>
private static Predicate<JsonAny> CreateDraft6IsSimpleType()
Expand Down Expand Up @@ -348,17 +348,17 @@ private static Action<IPropertyBuilder, TypeDeclaration, TypeDeclaration, HashSe
if (schema.AllOf.IsNotUndefined())
{
foreach (TypeDeclaration allOfTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => 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);
}
}
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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private static Predicate<JsonAny> CreateDraft7IsExplicitArrayType()
}

/// <summary>
/// Creates the predicate that determiens whether this schema represents a simple type.
/// Creates the predicate that determines whether this schema represents a simple type.
/// </summary>
/// <returns><see langword="true"/> if the schema is a simple type.</returns>
private static Predicate<JsonAny> CreateDraft7IsSimpleType()
Expand Down Expand Up @@ -351,7 +351,7 @@ private static Action<IPropertyBuilder, TypeDeclaration, TypeDeclaration, HashSe
if (schema.AllOf.IsNotUndefined())
{
foreach (TypeDeclaration allOfTypeDeclaration in source.RefResolvablePropertyDeclarations.Where(k => 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);
}
Expand All @@ -369,9 +369,9 @@ private static Action<IPropertyBuilder, TypeDeclaration, TypeDeclaration, HashSe
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);
}
}
Expand Down

0 comments on commit 29a0d46

Please sign in to comment.