NSwag icon indicating copy to clipboard operation
NSwag copied to clipboard

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

Open millennIumAMbiguity opened this issue 1 year ago • 1 comments

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 avatar Aug 02 '24 15:08 millennIumAMbiguity

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

millennIumAMbiguity avatar Aug 06 '24 19:08 millennIumAMbiguity