Skip to content

Commit b93f780

Browse files
authored
Merge pull request #30 from darkpatternsdigital/correct-any-schema
Correct any schema
2 parents 0dae1cc + eae821a commit b93f780

11 files changed

Lines changed: 48 additions & 15 deletions

File tree

.github/workflows/dotnet-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
env:
5454
VERSION_SUFFIX: ${{ github.ref != 'refs/heads/main' && github.sha || '' }}
5555
- name: 'Upload Code Coverage'
56-
uses: actions/upload-artifact@v3
56+
uses: actions/upload-artifact@v4
5757
with:
5858
name: code-coverage
5959
path: ./lib/*/TestResults/*/coverage.cobertura.xml

.github/workflows/dotnet-lint.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
name: Lint DotNet
22
on:
3-
pull_request:
4-
types: [edited, opened, reopened, synchronize, ready_for_review]
3+
workflow_dispatch: {}
4+
# Disabled because the 8.x format is unreliable with source generators
5+
# pull_request:
6+
# types: [edited, opened, reopened, synchronize, ready_for_review]
57

68
jobs:
79
build:

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
<OpenApiAbstractionsVersion>0.3.0</OpenApiAbstractionsVersion>
3333
<OpenApiJsonExtensionsVersion>0.18.0</OpenApiJsonExtensionsVersion>
3434
<OpenApiLoadersVersion>0.2.0</OpenApiLoadersVersion>
35-
<OpenApiCSharpVersion>0.25.0</OpenApiCSharpVersion>
36-
<OpenApiTypeScriptClientVersion>0.12.1</OpenApiTypeScriptClientVersion>
35+
<OpenApiCSharpVersion>0.25.1</OpenApiCSharpVersion>
36+
<OpenApiTypeScriptClientVersion>0.12.2</OpenApiTypeScriptClientVersion>
3737
<OpenApiTypeScriptRxjsClientVersion>0.9.0</OpenApiTypeScriptRxjsClientVersion>
3838
<OpenApiTypeScriptMswVersion>0.9.0</OpenApiTypeScriptMswVersion>
3939
<OpenApiTypeScriptFetchVersion>0.9.0</OpenApiTypeScriptFetchVersion>

eng/AutoCodeFormat.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<ItemGroup>
3-
<PackageReference Include="DarkPatterns.Build.Autoformat" Version="0.2.0" PrivateAssets="All" />
3+
<!-- <PackageReference Include="DarkPatterns.Build.Autoformat" Version="0.2.0" PrivateAssets="All" /> -->
44
</ItemGroup>
55

66
<PropertyGroup>

generators/typescript/npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@darkpatternsdigital/openapi-codegen-typescript",
3-
"version": "0.10.0",
3+
"version": "0.12.2",
44
"description": "A typescript client code generator for principled development",
55
"scripts": {
66
"build": "tsc -b tsconfig.build.json",

lib/OpenApi.CSharp/CSharpInlineSchemas.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public class CSharpInlineSchemas(CSharpSchemaOptions options, DocumentRegistry d
3434
var schemaInfo = CSharpTypeInfo.From(schema);
3535
CSharpInlineDefinition result = schemaInfo switch
3636
{
37+
{ Info.EffectiveSchema.BoolValue: false } => new(options.Find(TypeAnnotation.Common.Object, "never")),
38+
{ Info.EffectiveSchema.BoolValue: true } => new(options.Find(TypeAnnotation.Common.Object, "any")),
39+
{ Info.Annotations.Count: 0 } => new(options.Find(TypeAnnotation.Common.Object, "any")),
40+
3741
// Dictionary
3842
{ TypeAnnotation: { AllowsObject: true }, Properties: { Count: 0 }, AdditionalProperties: JsonSchema dictionaryValueSchema } =>
3943
new(options.ToMapType(ToInlineDataType(dictionaryValueSchema).Text), IsEnumerable: true),

lib/OpenApi.TypeScript/TypeScriptInlineSchemas.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ private TypeScriptInlineDefinition ForceConvertIntoInlineDataType(JsonSchemaInfo
103103
var typeInfo = TypeScriptTypeInfo.From(schemaInfo);
104104
TypeScriptInlineDefinition result = typeInfo switch
105105
{
106-
{ TypeAnnotation.AllowsArray: true, Items: null } => ArrayToInline(null),
107-
{ Items: JsonSchema items } => ArrayToInline(items),
108106
{ Info.EffectiveSchema.BoolValue: false } => new TypeScriptInlineDefinition("never", [], false, false),
109107
{ Info.EffectiveSchema.BoolValue: true } => new TypeScriptInlineDefinition("unknown", [], true, false),
108+
{ Info.Annotations.Count: 0 } =>
109+
new TypeScriptInlineDefinition("unknown", [], true, false),
110+
111+
{ TypeAnnotation.AllowsArray: true, Items: null } => ArrayToInline(null),
112+
{ Items: JsonSchema items } => ArrayToInline(items),
110113
{ TypeAnnotation: v3_0.TypeKeyword { OpenApiType: var primitiveType }, Format: var format } =>
111114
new(options.Find(TypeAnnotation.ToPrimitiveTypeString(primitiveType), format), []),
112115
{ TypeAnnotation.AllowsNumber: true, Format: var format } =>

lib/TestApp/Annotations/Controllers.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using static DarkPatterns.OpenApiCodegen.Server.Mvc.TestApp.OneOf.PetControllerBase;
2-
3-
namespace DarkPatterns.OpenApiCodegen.Server.Mvc.TestApp.Annotations
1+
namespace DarkPatterns.OpenApiCodegen.Server.Mvc.TestApp.Annotations
42
{
53
public class DogController : DogControllerBase
64
{

lib/TestApp/Any/Controllers.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Text.Json.Nodes;
2+
3+
namespace DarkPatterns.OpenApiCodegen.Server.Mvc.TestApp.Any;
4+
5+
public class DataController : DataControllerBase
6+
{
7+
protected override Task<GetDataActionResult> GetData()
8+
{
9+
throw new NotImplementedException();
10+
}
11+
12+
protected override Task<PutDataActionResult> PutData(JsonNode putDataBody)
13+
{
14+
throw new NotImplementedException();
15+
}
16+
}

lib/TestApp/OpenApiCodegen.Server.Mvc.TestApp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<ItemGroup>
1414
<OpenApiSchemaClient Include="$(SolutionRoot)schemas\all-of.yaml" Link="Clients\AllOf\all-of.yaml" />
1515
<OpenApiSchemaMvcServer Include="$(SolutionRoot)schemas\all-of.yaml" Link="AllOf\all-of.yaml" PathPrefix="/all-of" />
16+
<OpenApiSchemaMvcServer Include="$(SolutionRoot)schemas\any.yaml" Link="Any\any.yaml" PathPrefix="/any" />
1617
<OpenApiSchemaMvcServer Include="$(SolutionRoot)schemas\enum.yaml" Link="Enum\enum.yaml" PathPrefix="/enum" />
1718
<OpenApiSchemaMvcServer Include="$(SolutionRoot)schemas\controller-extension.yaml" Link="ControllerExtensions\controller-extension.yaml" PathPrefix="/controller-extensions" />
1819
<OpenApiSchemaMvcServer Include="$(SolutionRoot)schemas\csharp-name-override.yaml" Link="CSharpNameOverride\csharp-name-override.yaml" PathPrefix="/csharp-name-override" />

0 commit comments

Comments
 (0)