Skip to content

[BUG] csharp-netcore generates invalid code #9442

@aeneasr

Description

@aeneasr

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Generating code with discriminators leads the dotnet generator to fail

/Users/foobar/workspace/go/src/github.com/ory/sdk/clients/kratos/dotnet/src/Ory.Keto.Client/Model/KratosUiNodeInputAttributesValue.cs(46,35): error CS0019: Operator '??' cannot be applied to operands of type 'bool' and '<throw expression>' [/Users/foobar/workspace/go/src/github.com/ory/sdk/clients/kratos/dotnet/src/Ory.Keto.Client/Ory.Keto.Client.csproj]
/Users/foobar/workspace/go/src/github.com/ory/sdk/clients/kratos/dotnet/src/Ory.Keto.Client/Model/KratosUiNodeInputAttributesValue.cs(58,35): error CS0019: Operator '??' cannot be applied to operands of type 'decimal' and '<throw expression>' [/Users/foobar/workspace/go/src/github.com/ory/sdk/clients/kratos/dotnet/src/Ory.Keto.Client/Ory.Keto.Client.csproj]
openapi-generator version

5.1.1

OpenAPI declaration file content or url

API Specification

Generation Details
$ openapi-generator-cli generate -i "${SPEC_FILE}" \
    -g csharp-netcore \
    -o "$dir" \
    --model-name-prefix ${PROJECT_UCF} \
    --git-user-id ory \
    --git-repo-id sdk \
    --git-host github.com \
    -c ./config/client/dotnet.yml.proc.yml
# ./config/client/dotnet.yml.proc.yml
licenseId: Apache-2.0
packageName: "Ory.Keto.Client"
packageVersion: 0.0.0-alpha.55
packageAuthors: ORY
packageCompany: ORY GmbH
netCoreProjectFile: true
infoUrl: https://www.ory.sh
targetFramework: net5.0
disallowAdditionalPropertiesIfNotPresent: false
Steps to reproduce

See above

Related issues/PRs

None

Suggest a fix

I would love to have an idea but I am not a dotnet developer :(

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions