Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum merging schema transformer #17

Open
RicoSuter opened this issue Jan 13, 2016 · 5 comments
Open

Enum merging schema transformer #17

RicoSuter opened this issue Jan 13, 2016 · 5 comments

Comments

@RicoSuter
Copy link
Owner

See RicoSuter/NSwag#29

@RicoSuter RicoSuter changed the title Enum merging (feature) - TypeScript Enum merging schema transformer Mar 25, 2016
@RicoSuter
Copy link
Owner Author

Should look like:

var schema = JsonSchema4.FromType<Person>();

var transformation = new MergeEnumerationsTransformation();
transformation.Transform(schema);

var json = schema.ToJson();

Compare enum schemes by serializing the schema and compare the strings...

@arutkowski00
Copy link

arutkowski00 commented Aug 11, 2017

I have exactly the same issue. Look at the generated TS code:

export enum SortDir {
    Undefined = 0,
    Asc = 1,
    Desc = 2,
}

export enum sortDir {
    Undefined = 0,
    Asc = 1,
    Desc = 2,
}

export enum sortDir2 {
    Undefined = 0,
    Asc = 1,
    Desc = 2,
}

export enum sortDir3 {
    Undefined = 0,
    Asc = 1,
    Desc = 2,
}

export enum sortDir4 {
    Undefined = 0,
    Asc = 1,
    Desc = 2,
}

export enum sortDir5 {
    Undefined = 0,
    Asc = 1,
    Desc = 2,
}

@RicoSuter
Copy link
Owner Author

Maybe insteadof modifing the doc we could also integrate this into the resolver and merge on the fly?

@kpol
Copy link

kpol commented Oct 17, 2018

I created this simple class https://gist.github.com/kpol/3e76ecf37024d4be364f8a5782557f9a to merge enums based on enum fullname (added this metadata as a vendor extension on service-side [Swashbuckle]). This class pre-process Swagger spec file for NSwag
Swagger spec example:

{
	"name": "enumA",
	"in": "query",
	"required": true,
	"type": "string",
	"enum": ["A", "B"],
	"x-nullable": false,
	"x-type-fullname": "WebTest.EnumA"
}

@RouR
Copy link

RouR commented Jul 20, 2019

@kpol How to use it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants