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 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/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 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", 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/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 { 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 +