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
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/dotnet-lint.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
<OpenApiAbstractionsVersion>0.3.0</OpenApiAbstractionsVersion>
<OpenApiJsonExtensionsVersion>0.18.0</OpenApiJsonExtensionsVersion>
<OpenApiLoadersVersion>0.2.0</OpenApiLoadersVersion>
<OpenApiCSharpVersion>0.25.0</OpenApiCSharpVersion>
<OpenApiTypeScriptClientVersion>0.12.1</OpenApiTypeScriptClientVersion>
<OpenApiCSharpVersion>0.25.1</OpenApiCSharpVersion>
<OpenApiTypeScriptClientVersion>0.12.2</OpenApiTypeScriptClientVersion>
<OpenApiTypeScriptRxjsClientVersion>0.9.0</OpenApiTypeScriptRxjsClientVersion>
<OpenApiTypeScriptMswVersion>0.9.0</OpenApiTypeScriptMswVersion>
<OpenApiTypeScriptFetchVersion>0.9.0</OpenApiTypeScriptFetchVersion>
Expand Down
2 changes: 1 addition & 1 deletion eng/AutoCodeFormat.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<ItemGroup>
<PackageReference Include="DarkPatterns.Build.Autoformat" Version="0.2.0" PrivateAssets="All" />
<!-- <PackageReference Include="DarkPatterns.Build.Autoformat" Version="0.2.0" PrivateAssets="All" /> -->
</ItemGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion generators/typescript/npm/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 4 additions & 0 deletions lib/OpenApi.CSharp/CSharpInlineSchemas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
7 changes: 5 additions & 2 deletions lib/OpenApi.TypeScript/TypeScriptInlineSchemas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 } =>
Expand Down
4 changes: 1 addition & 3 deletions lib/TestApp/Annotations/Controllers.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
16 changes: 16 additions & 0 deletions lib/TestApp/Any/Controllers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Text.Json.Nodes;

namespace DarkPatterns.OpenApiCodegen.Server.Mvc.TestApp.Any;

public class DataController : DataControllerBase
{
protected override Task<GetDataActionResult> GetData()
{
throw new NotImplementedException();
}

protected override Task<PutDataActionResult> PutData(JsonNode putDataBody)
{
throw new NotImplementedException();
}
}
1 change: 1 addition & 0 deletions lib/TestApp/OpenApiCodegen.Server.Mvc.TestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ItemGroup>
<OpenApiSchemaClient Include="$(SolutionRoot)schemas\all-of.yaml" Link="Clients\AllOf\all-of.yaml" />
<OpenApiSchemaMvcServer Include="$(SolutionRoot)schemas\all-of.yaml" Link="AllOf\all-of.yaml" PathPrefix="/all-of" />
<OpenApiSchemaMvcServer Include="$(SolutionRoot)schemas\any.yaml" Link="Any\any.yaml" PathPrefix="/any" />
<OpenApiSchemaMvcServer Include="$(SolutionRoot)schemas\enum.yaml" Link="Enum\enum.yaml" PathPrefix="/enum" />
<OpenApiSchemaMvcServer Include="$(SolutionRoot)schemas\controller-extension.yaml" Link="ControllerExtensions\controller-extension.yaml" PathPrefix="/controller-extensions" />
<OpenApiSchemaMvcServer Include="$(SolutionRoot)schemas\csharp-name-override.yaml" Link="CSharpNameOverride\csharp-name-override.yaml" PathPrefix="/csharp-name-override" />
Expand Down
15 changes: 12 additions & 3 deletions schemas/any.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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