From 7e1cf0e51ffe045456990e81e048fde319cdb926 Mon Sep 17 00:00:00 2001 From: Matt DeKrey Date: Thu, 29 May 2025 19:47:16 -0500 Subject: [PATCH 1/5] Remove unneeded using statement --- lib/TestApp/Annotations/Controllers.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/TestApp/Annotations/Controllers.cs b/lib/TestApp/Annotations/Controllers.cs index 0e27bc70..bb3ae4b1 100644 --- a/lib/TestApp/Annotations/Controllers.cs +++ b/lib/TestApp/Annotations/Controllers.cs @@ -1,6 +1,4 @@ -using static DarkPatterns.OpenApiCodegen.Server.Mvc.TestApp.OneOf.PetControllerBase; - -namespace DarkPatterns.OpenApiCodegen.Server.Mvc.TestApp.Annotations +namespace DarkPatterns.OpenApiCodegen.Server.Mvc.TestApp.Annotations { public class DogController : DogControllerBase { From e427192495aa27155524d622757d9b38b6d1a60d Mon Sep 17 00:00:00 2001 From: Matt DeKrey Date: Thu, 29 May 2025 20:20:19 -0500 Subject: [PATCH 2/5] Expand handling of empty and boolean schemas --- lib/OpenApi.CSharp/CSharpInlineSchemas.cs | 4 ++++ .../TypeScriptInlineSchemas.cs | 7 +++++-- lib/TestApp/Any/Controllers.cs | 16 ++++++++++++++++ .../OpenApiCodegen.Server.Mvc.TestApp.csproj | 1 + schemas/any.yaml | 15 ++++++++++++--- 5 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 lib/TestApp/Any/Controllers.cs diff --git a/lib/OpenApi.CSharp/CSharpInlineSchemas.cs b/lib/OpenApi.CSharp/CSharpInlineSchemas.cs index b3e3349f..bd245e92 100644 --- a/lib/OpenApi.CSharp/CSharpInlineSchemas.cs +++ b/lib/OpenApi.CSharp/CSharpInlineSchemas.cs @@ -34,6 +34,10 @@ public class CSharpInlineSchemas(CSharpSchemaOptions options, DocumentRegistry d var schemaInfo = CSharpTypeInfo.From(schema); CSharpInlineDefinition result = schemaInfo switch { + { Info.EffectiveSchema.BoolValue: false } => new(options.Find(TypeAnnotation.Common.Object, "never")), + { Info.EffectiveSchema.BoolValue: true } => new(options.Find(TypeAnnotation.Common.Object, "any")), + { Info.Annotations.Count: 0 } => new(options.Find(TypeAnnotation.Common.Object, "any")), + // Dictionary { TypeAnnotation: { AllowsObject: true }, Properties: { Count: 0 }, AdditionalProperties: JsonSchema dictionaryValueSchema } => new(options.ToMapType(ToInlineDataType(dictionaryValueSchema).Text), IsEnumerable: true), diff --git a/lib/OpenApi.TypeScript/TypeScriptInlineSchemas.cs b/lib/OpenApi.TypeScript/TypeScriptInlineSchemas.cs index 91a3ddfb..6e2d5c70 100644 --- a/lib/OpenApi.TypeScript/TypeScriptInlineSchemas.cs +++ b/lib/OpenApi.TypeScript/TypeScriptInlineSchemas.cs @@ -103,10 +103,13 @@ private TypeScriptInlineDefinition ForceConvertIntoInlineDataType(JsonSchemaInfo var typeInfo = TypeScriptTypeInfo.From(schemaInfo); TypeScriptInlineDefinition result = typeInfo switch { - { TypeAnnotation.AllowsArray: true, Items: null } => ArrayToInline(null), - { Items: JsonSchema items } => ArrayToInline(items), { Info.EffectiveSchema.BoolValue: false } => new TypeScriptInlineDefinition("never", [], false, false), { Info.EffectiveSchema.BoolValue: true } => new TypeScriptInlineDefinition("unknown", [], true, false), + { Info.Annotations.Count: 0 } => + new TypeScriptInlineDefinition("unknown", [], true, false), + + { TypeAnnotation.AllowsArray: true, Items: null } => ArrayToInline(null), + { Items: JsonSchema items } => ArrayToInline(items), { TypeAnnotation: v3_0.TypeKeyword { OpenApiType: var primitiveType }, Format: var format } => new(options.Find(TypeAnnotation.ToPrimitiveTypeString(primitiveType), format), []), { TypeAnnotation.AllowsNumber: true, Format: var format } => diff --git a/lib/TestApp/Any/Controllers.cs b/lib/TestApp/Any/Controllers.cs new file mode 100644 index 00000000..470b9bb8 --- /dev/null +++ b/lib/TestApp/Any/Controllers.cs @@ -0,0 +1,16 @@ +using System.Text.Json.Nodes; + +namespace DarkPatterns.OpenApiCodegen.Server.Mvc.TestApp.Any; + +public class DataController : DataControllerBase +{ + protected override Task GetData() + { + throw new NotImplementedException(); + } + + protected override Task PutData(JsonNode putDataBody) + { + throw new NotImplementedException(); + } +} diff --git a/lib/TestApp/OpenApiCodegen.Server.Mvc.TestApp.csproj b/lib/TestApp/OpenApiCodegen.Server.Mvc.TestApp.csproj index bfad28ab..19fabb01 100644 --- a/lib/TestApp/OpenApiCodegen.Server.Mvc.TestApp.csproj +++ b/lib/TestApp/OpenApiCodegen.Server.Mvc.TestApp.csproj @@ -13,6 +13,7 @@ + diff --git a/schemas/any.yaml b/schemas/any.yaml index 13685254..ef4c070d 100644 --- a/schemas/any.yaml +++ b/schemas/any.yaml @@ -12,6 +12,15 @@ paths: description: Gets any kind of JSON data content: application/json: - schema: - type: object - format: any + schema: {} + put: + operationId: putData + requestBody: + required: true + content: + application/json: + schema: {} + responses: + '200': + description: Data received + From 5f1dd14953aa5b0960e88be0ac81f1537a9e8389 Mon Sep 17 00:00:00 2001 From: Matt DeKrey Date: Thu, 29 May 2025 20:36:26 -0500 Subject: [PATCH 3/5] Bump packge versions --- Directory.Build.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index ef55a663..9ed0b88f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -32,8 +32,8 @@ 0.3.0 0.18.0 0.2.0 - 0.25.0 - 0.12.1 + 0.25.1 + 0.12.2 0.9.0 0.9.0 0.9.0 From 53039e303d872521a9de68cc787934e1489a3c0b Mon Sep 17 00:00:00 2001 From: Matt DeKrey Date: Thu, 29 May 2025 20:43:10 -0500 Subject: [PATCH 4/5] Bump action version --- .github/workflows/dotnet-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index a09f68df..c9a816d1 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -53,7 +53,7 @@ jobs: env: VERSION_SUFFIX: ${{ github.ref != 'refs/heads/main' && github.sha || '' }} - name: 'Upload Code Coverage' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: code-coverage path: ./lib/*/TestResults/*/coverage.cobertura.xml From eae821ae9db4b605f8dc020eda450ba3e6c0cda3 Mon Sep 17 00:00:00 2001 From: Matt DeKrey Date: Thu, 29 May 2025 21:38:06 -0500 Subject: [PATCH 5/5] Disable 8.0.410 `dotnet-format` command --- .github/workflows/dotnet-lint.yml | 6 ++++-- eng/AutoCodeFormat.targets | 2 +- generators/typescript/npm/package.json | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dotnet-lint.yml b/.github/workflows/dotnet-lint.yml index ec41f0a1..08149ead 100644 --- a/.github/workflows/dotnet-lint.yml +++ b/.github/workflows/dotnet-lint.yml @@ -1,7 +1,9 @@ name: Lint DotNet on: - pull_request: - types: [edited, opened, reopened, synchronize, ready_for_review] + workflow_dispatch: {} + # Disabled because the 8.x format is unreliable with source generators + # pull_request: + # types: [edited, opened, reopened, synchronize, ready_for_review] jobs: build: diff --git a/eng/AutoCodeFormat.targets b/eng/AutoCodeFormat.targets index c0b9ab03..b9e94506 100644 --- a/eng/AutoCodeFormat.targets +++ b/eng/AutoCodeFormat.targets @@ -1,6 +1,6 @@ - + diff --git a/generators/typescript/npm/package.json b/generators/typescript/npm/package.json index 2d8e62ef..2f1b5167 100644 --- a/generators/typescript/npm/package.json +++ b/generators/typescript/npm/package.json @@ -1,6 +1,6 @@ { "name": "@darkpatternsdigital/openapi-codegen-typescript", - "version": "0.10.0", + "version": "0.12.2", "description": "A typescript client code generator for principled development", "scripts": { "build": "tsc -b tsconfig.build.json",