Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
- name: Setup .NET
id: dotnet
uses: actions/setup-dotnet@v5
uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ env.dotnet_version }}
- name: Build
Expand All @@ -49,5 +49,6 @@ jobs:
project_path: ${{ needs.test.outputs.project_path }}
project_name: ${{ needs.test.outputs.project_name }}
dotnet_version: ${{ needs.test.outputs.dotnet_version }}
include_github_release_notes: true
secrets:
nuget_api_key: ${{ secrets.NUGET_API_KEY }}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ Supported data formats are:
3. Add references to [Corvus.Json.ExtendedTypes](https://github.com/corvus-dotnet/Corvus.JsonSchema?tab=readme-ov-file#corvusjsonextendedtypes) and [ParameterStyleParsers.OpenAPI](https://github.com/Fresa/OpenAPI.ParameterStyleParsers).
```
<ItemGroup>
<PackageReference Include="Corvus.Json.ExtendedTypes" Version="4.3.13" />
<PackageReference Include="ParameterStyleParsers.OpenAPI" Version="1.4.0" />
<PackageReference Include="Corvus.Json.ExtendedTypes" Version="5.5.5" />
<PackageReference Include="ParameterStyleParsers.OpenAPI" Version="1.5.0" />
</ItemGroup>
```
* Corvus.Json.ExtendedTypes >= 4.0.0
* Corvus.Json.ExtendedTypes >= 5.0.0
* ParameterStyleParsers.OpenAPI >= 1.4.0

4. Compile the project.
Expand Down
10 changes: 6 additions & 4 deletions src/OpenAPI.WebApiGenerator/CodeGeneration/SchemaGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,16 @@ private List<TypeDeclaration> GenerateCode(SourceGeneratorHelpers.TypesToGenerat

var generatedCode = typeBuilder.GenerateCodeUsing(
languageProvider,
context.CancellationToken,
typeDeclarationsToGenerate);
typeDeclarationsToGenerate,
context.CancellationToken);

foreach (var codeFile in generatedCode)
{
context.CancellationToken.ThrowIfCancellationRequested();

var filePath = namespaceToPathConversion[codeFile.TypeDeclaration.DotnetNamespace()];

var filePath = namespaceToPathConversion[
codeFile.TypeDeclaration?.DotnetNamespace() ?? throw new InvalidOperationException(
$"Code file {codeFile.FileName} does not have a namespace. This is an internal implementation error.")];
var fileName = Path.Combine(filePath, codeFile.FileName);

// Deduplicate nested schemas that might already have been generated
Expand Down
4 changes: 2 additions & 2 deletions src/OpenAPI.WebApiGenerator/OpenAPI.WebApiGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" PrivateAssets="all" GeneratePathProperty="true" />
<PackageReference Include="Corvus.Json.SourceGeneratorTools" Version="4.4.3" PrivateAssets="all" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="6.0.0" PrivateAssets="all" GeneratePathProperty="true" />
<PackageReference Include="Corvus.Json.SourceGeneratorTools" Version="5.5.5" PrivateAssets="all" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
16 changes: 16 additions & 0 deletions tests/Example.OpenApi20/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Example.OpenApi20.Parameters.FooId.op_Implicit(Example.OpenApi20.Parameters.FooId)~System.Int64</Target>
<Left>LastMajorVersionBinary/Example.OpenApi20.dll</Left>
<Right>obj/net9.0/Example.OpenApi20.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Example.OpenApi20.Parameters.FooId.op_Implicit(System.Int64)~Example.OpenApi20.Parameters.FooId</Target>
<Left>LastMajorVersionBinary/Example.OpenApi20.dll</Left>
<Right>obj/net9.0/Example.OpenApi20.dll</Right>
</Suppression>
</Suppressions>
2 changes: 1 addition & 1 deletion tests/Example.OpenApi20/Example.OpenApi20.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Corvus.Json.ExtendedTypes" Version="4.4.2" />
<PackageReference Include="Corvus.Json.ExtendedTypes" Version="5.5.5" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.12" />
<PackageReference Include="Microsoft.DotNet.ApiCompat.Task" Version="10.0.202" PrivateAssets="all" IsImplicitlyDefined="true" />
<PackageReference Include="ParameterStyleParsers.OpenAPI" Version="1.5.0" />
Expand Down
2 changes: 1 addition & 1 deletion tests/Example.OpenApi30/Example.OpenApi30.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Corvus.Json.ExtendedTypes" Version="4.4.2" />
<PackageReference Include="Corvus.Json.ExtendedTypes" Version="5.5.5" />
<PackageReference Include="Microsoft.DotNet.ApiCompat.Task" Version="10.0.202" PrivateAssets="all" IsImplicitlyDefined="true" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="9.0.12" />
Expand Down
2 changes: 1 addition & 1 deletion tests/Example.OpenApi31/Example.OpenApi31.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Corvus.Json.ExtendedTypes" Version="4.4.2" />
<PackageReference Include="Corvus.Json.ExtendedTypes" Version="5.5.5" />
<PackageReference Include="Microsoft.DotNet.ApiCompat.Task" Version="10.0.202" PrivateAssets="all" IsImplicitlyDefined="true" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Certificate" Version="9.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.12" />
Expand Down
2 changes: 1 addition & 1 deletion tests/Example.OpenApi32/Example.OpenApi32.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Corvus.Json.ExtendedTypes" Version="4.4.2" />
<PackageReference Include="Corvus.Json.ExtendedTypes" Version="5.5.5" />
<PackageReference Include="Microsoft.DotNet.ApiCompat.Task" Version="10.0.202" PrivateAssets="all" IsImplicitlyDefined="true" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Certificate" Version="9.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.12" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="AwesomeAssertions" Version="9.0.0" />
<PackageReference Include="Corvus.Json.SourceGeneratorTools" Version="4.4.3" />
<PackageReference Include="Corvus.Json.SourceGeneratorTools" Version="5.5.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2"/>
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="AwesomeAssertions" Version="9.0.0" />
<PackageReference Include="Corvus.Json.SourceGeneratorTools" Version="4.4.3" />
<PackageReference Include="Corvus.Json.SourceGeneratorTools" Version="5.5.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2"/>
<PackageReference Include="Microsoft.OpenApi" Version="3.5.4" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
Expand Down