Skip to content

Commit

Permalink
Update Json-related Corvus libraries. (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
jongeorge1 authored Mar 8, 2021
1 parent 3b6e54c commit df54a28
Show file tree
Hide file tree
Showing 26 changed files with 93 additions and 65 deletions.
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ branches:
regex: ^master
tag: preview
increment: patch
next-version: "1.2"
next-version: "2.0"

4 changes: 2 additions & 2 deletions Solutions/Menes.Abstractions/Menes.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Corvus.ContentHandling" Version="1.1.0" />
<PackageReference Include="Corvus.ContentHandling" Version="2.0.3" />
<PackageReference Include="Corvus.Extensions" Version="1.1.2" />
<PackageReference Include="Corvus.Extensions.Newtonsoft.Json" Version="1.2.0" />
<PackageReference Include="Corvus.Extensions.Newtonsoft.Json" Version="2.0.1" />
<PackageReference Include="Corvus.Monitoring.Instrumentation.Abstractions" Version="1.2.0" />
<PackageReference Include="Endjin.RecommendedPractices" Version="1.2.0">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static IServiceCollection AddOpenApiHosting<TRequest, TResponse>(
return services;
}

services.AddJsonSerializerSettings();
services.AddJsonNetSerializerSettingsProvider();

services.AddInstrumentation();

Expand Down
20 changes: 18 additions & 2 deletions Solutions/Menes.PetStore.Hosting/Menes/PetStore/Hosting/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace Menes.PetStore.Hosting
using Menes.PetStore.Responses.Mappers;
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

/// <summary>
/// Startup code for the Function.
Expand All @@ -24,15 +26,29 @@ public override void Configure(IFunctionsHostBuilder builder)
services.AddLogging();
services.AddHttpClient();

services.AddHalDocumentMapper<PetResource, PetResourceMapper>();
services.AddHalDocumentMapper<PetListResource, PetListResourceMapper>();
ConfigureMenes(services);

// This converter used to be added by default as part of Menes v1.x initialisation, but this is no longer
// the case in v2.0 onwards. However, we have specified that our pets will have their Size value, which is
// represented by the Size enumeration, returned as a string. This conversion could be done manually in the
// PetResourceMapper, but we can achieve the same goal using the StringEnumConverter.
services.AddSingleton<JsonConverter>(new StringEnumConverter(true));
}

private static void ConfigureMenes(IServiceCollection services)
{
// Main Menes setup call.
services.AddOpenApiHttpRequestHosting<SimpleOpenApiContext>(LoadDocuments);

// We can add all the services here
// We will only actually *provide* services that are in the YAML file(s) we load below
// So you can register everything, and use the yaml files you deploy to decide what is responded to by this instance
services.AddSingleton<IOpenApiService, PetStoreService>();

// Mappers for our return types. These use the special AddHalDocumentMapper extension, which will ensure
// that their ConfigureLinkMap methods are added as part of initialisation.
services.AddHalDocumentMapper<PetResource, PetResourceMapper>();
services.AddHalDocumentMapper<PetListResource, PetListResourceMapper>();
}

private static void LoadDocuments(IOpenApiHostConfiguration hostConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void ConfigureCommonServices(ScenarioContext scenarioContext)
services =>
{
services.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Debug));
services.AddJsonSerializerSettings();
services.AddJsonNetSerializerSettingsProvider();
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions Solutions/Menes.PetStore.Specs/Features/CreatePet.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Solutions/Menes.PetStore.Specs/Features/GetPetById.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Solutions/Menes.PetStore.Specs/Features/ListPets.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Solutions/Menes.PetStore/Menes/PetStore/PetStore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ components:
properties:
self:
$ref: "#/components/schemas/Link"
image:
$ref: "#/components/schemas/Link"
pocoimage:
$ref: "#/components/schemas/Link"

PetList:
anyOf:
Expand All @@ -354,6 +358,10 @@ components:
$ref: "#/components/schemas/Link"
pets:
$ref: "#/components/schemas/LinkCollection"
create:
$ref: "#/components/schemas/Link"
next:
$ref: "#/components/schemas/Link"
_embedded:
type: object
properties:
Expand Down
6 changes: 3 additions & 3 deletions Solutions/Menes.Specs/Features/AccessControlPolicy.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Solutions/Menes.Specs/Features/HalDocument{T}.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit df54a28

Please sign in to comment.