Skip to content

[Feature] Enum types from strings or metadata #146

Open
@ghost

Description

Here is a schema.json that demonstrates the issue.

When "enum" schema components are encountered in json schema, SwaggerProvider seems to strip their info away and just label the type as strings or int (depending on JsonStringEnumConverter).

This makes working with APIs a bit painful. Azure seems to deal with this issue using x-ms-enum which means it would add meta data for codegen (regardless of if its an int or string encoding for enum value).

Code to demonstrate issue, noting that it is not possible to even create a TaskType, one has to work out what the valid values are by looking at the raw JSON schema (and hoping it doesn't change like it did for me):

open SwaggerProvider

type Api = OpenApiClientProvider<"schema.json">
let client = Api.Client()
client.GetApiAdminTest("aosdijoasjid") |> ignore

It would be nice if SwaggerProvider could generate this:
type TaskType = This | That | Other based on x-ms-enum or string

Related information

NET Core SDK & Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions