I'm trying to generate a C# client from the OpenRouter OpenAPI spec:

https://github.com/OpenRouterTeam/typescript-sdk/blob/main/.speakeasy/in.openapi.yaml

Among other things there are some enums defined like the following:

        reasoning:
          type: object
          properties:
            effort:
              anyOf:
                - type: string
                  enum:
                    - minimal
                    - low
                    - medium
                    - high
                - type: 'null'

This results in NSwag tooling not being able to generate a valid code. As far as I understand, it tries to combine the types by inheriting a class from a enum (which is not possible already) so that it can be nullable (instead of using Nullable<MyEnum> or something). Also it ignores the fact that the actual type is string so there absolutely can and will be unexpected values ("open enums") which the client will not be able to handle gracefully.

Is there any way to configure NSwag to make some sense out of it? Like, making a proper string? property and a class listing some string constants? Or maybe another standard solution to that?

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.