diff --git a/AdminApi/test/AdminApi.Tests.Integration/AdminApi.Tests.Integration.csproj b/AdminApi/test/AdminApi.Tests.Integration/AdminApi.Tests.Integration.csproj index 377c0dccb8..7893f6f3ef 100644 --- a/AdminApi/test/AdminApi.Tests.Integration/AdminApi.Tests.Integration.csproj +++ b/AdminApi/test/AdminApi.Tests.Integration/AdminApi.Tests.Integration.csproj @@ -5,13 +5,14 @@ - + + diff --git a/AdminApi/test/AdminApi.Tests.Integration/Models/ChangeClientSecretResponse.cs b/AdminApi/test/AdminApi.Tests.Integration/Models/ChangeClientSecretResponse.cs index e9ad74911e..6ad1825d25 100644 --- a/AdminApi/test/AdminApi.Tests.Integration/Models/ChangeClientSecretResponse.cs +++ b/AdminApi/test/AdminApi.Tests.Integration/Models/ChangeClientSecretResponse.cs @@ -1,9 +1,11 @@ namespace Backbone.AdminApi.Tests.Integration.Models; + public class ChangeClientSecretResponse { public required string ClientId { get; set; } public required string DisplayName { get; set; } public required string ClientSecret { get; set; } + public required string DefaultTier { get; set; } public required DateTime CreatedAt { get; set; } public int? MaxIdentities { get; set; } } diff --git a/AdminApi/test/AdminApi.Tests.Integration/Support/JsonValidators.cs b/AdminApi/test/AdminApi.Tests.Integration/Support/JsonValidators.cs index ba4137df39..996ea8a26c 100644 --- a/AdminApi/test/AdminApi.Tests.Integration/Support/JsonValidators.cs +++ b/AdminApi/test/AdminApi.Tests.Integration/Support/JsonValidators.cs @@ -1,7 +1,9 @@ +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Schema; -using Newtonsoft.Json.Schema.Generation; using Newtonsoft.Json.Serialization; +using NJsonSchema.NewtonsoftJson.Generation; +using JsonSchemaGenerator = NJsonSchema.Generation.JsonSchemaGenerator; namespace Backbone.AdminApi.Tests.Integration.Support; @@ -17,14 +19,28 @@ public static bool ValidateJsonSchema(string json, out IList errors) return parsedJson.IsValid(schema, out errors); } - var generator = new JSchemaGenerator + var settings = new NewtonsoftJsonSchemaGeneratorSettings { - ContractResolver = new CamelCasePropertyNamesContractResolver() + SerializerSettings = new JsonSerializerSettings + { + ContractResolver = new CamelCasePropertyNamesContractResolver() + } }; + + var generator = new JsonSchemaGenerator(settings); + var schemaJson = generator.Generate(typeof(T)); - schema = JSchema.Parse(schemaJson.ToString()); + + var generatedSchema = schemaJson.ToJson(); + + schema = JSchema.Parse(generatedSchema); + + schema.AllowAdditionalProperties = true; + CACHED_SCHEMAS.Add(typeof(T), schema); + var responseJson = JObject.Parse(json); + return responseJson.IsValid(schema, out errors); } } diff --git a/ConsumerApi.Tests.Integration/ConsumerApi.Tests.Integration.csproj b/ConsumerApi.Tests.Integration/ConsumerApi.Tests.Integration.csproj index 66336fca88..859036c8f5 100644 --- a/ConsumerApi.Tests.Integration/ConsumerApi.Tests.Integration.csproj +++ b/ConsumerApi.Tests.Integration/ConsumerApi.Tests.Integration.csproj @@ -5,7 +5,7 @@ - + @@ -13,6 +13,7 @@ + diff --git a/ConsumerApi.Tests.Integration/Support/JsonValidators.cs b/ConsumerApi.Tests.Integration/Support/JsonValidators.cs index fc5858a5e9..31c03b152e 100644 --- a/ConsumerApi.Tests.Integration/Support/JsonValidators.cs +++ b/ConsumerApi.Tests.Integration/Support/JsonValidators.cs @@ -1,7 +1,9 @@ +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Schema; -using Newtonsoft.Json.Schema.Generation; using Newtonsoft.Json.Serialization; +using NJsonSchema.NewtonsoftJson.Generation; +using JsonSchemaGenerator = NJsonSchema.Generation.JsonSchemaGenerator; namespace Backbone.ConsumerApi.Tests.Integration.Support; @@ -17,14 +19,28 @@ public static bool ValidateJsonSchema(string json, out IList errors) return parsedJson.IsValid(schema, out errors); } - var generator = new JSchemaGenerator + var settings = new NewtonsoftJsonSchemaGeneratorSettings { - ContractResolver = new CamelCasePropertyNamesContractResolver() + SerializerSettings = new JsonSerializerSettings + { + ContractResolver = new CamelCasePropertyNamesContractResolver() + } }; + + var generator = new JsonSchemaGenerator(settings); + var schemaJson = generator.Generate(typeof(T)); - schema = JSchema.Parse(schemaJson.ToString()); + + var generatedSchema = schemaJson.ToJson(); + + schema = JSchema.Parse(generatedSchema); + + schema.AllowAdditionalProperties = true; + CACHED_SCHEMAS.Add(typeof(T), schema); + var responseJson = JObject.Parse(json); + return responseJson.IsValid(schema, out errors); } }