RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.78k stars 1.29k forks source link

"Cannot inherit from sealed struct 'int'" and "Cannot resolve symbol 'XX'" in generated client code #4952

Open millennIumAMbiguity opened 3 months ago

millennIumAMbiguity commented 3 months ago

I have two errors in the generated client code that I cannot resolve.

based on this document, I use netframework-4.6.2 I use openapi 3.0.3 In my nswag.json, I have "runtime": "WinX64"

I get "Cannot resolve symbol 'XX'" from this generated code:

 if (status_ == 4XX)

I get "Cannot inherit from sealed struct 'int'" from this generated code:

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class SceneId : int
{

}

The openApi for SceneId looks like this:

    SceneId:
      allOf:
        - $ref: "#/components/schemas/int32"
        - minimum: -1

"#/components/schemas/int32" looks like this:

    int32:
      description:
        An integer safely representable using a *signed 32-bit integer* type.
      type: integer
      minimum: -2147483648
      maximum: 2147483647
millennIumAMbiguity commented 2 months ago

the issue with "Cannot inherit from sealed struct 'int'" is because of unsupported usage of allOf: