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

Partial namespace in SchemaId #333

Closed
henkosch opened this issue May 16, 2015 · 5 comments
Closed

Partial namespace in SchemaId #333

henkosch opened this issue May 16, 2015 · 5 comments
Milestone

Comments

@henkosch
Copy link

I have many complex models in my API.
They have full type names like this:

MyProject.Api.Interface.Models.Category1.Type1
MyProject.Api.Interface.Models.Category1.Type2
MyProject.Api.Interface.Models.Category2.Type1
MyProject.Api.Interface.Models.Category2.Type2

As you can see I have two different types with the class name Type1, so currently I'm using UseFullTypeNameInSchemaIds() configuration to avoid collision.

But I want to make my SchemaIds shorter like this:

Category1.Type1
Category1.Type2
Category2.Type1
Category2.Type2

How could I achieve this?
I have tried to create a custom ISchemaFilter, but I could not find a way to change the SchemaId.

@domaindrivendev
Copy link
Owner

Unfortunately the only way to do this right now would be with a DocumentFilter. You would have to replace the "definitions" dictionary, transforming the keys accordingly as well as iterating and updating all Schema refs throughout the document.

You may be quicker to submit a PR. In this, you could update the generator options to include a strategy (lambda) for schemaIds then wire up a default implementation that uses the existing approach

@domaindrivendev domaindrivendev added this to the v6.0.0 milestone Jun 4, 2015
@SquigNob
Copy link

SquigNob commented Jun 6, 2015

I also need this feture so have added PR #377

@gambrose
Copy link
Contributor

gambrose commented Jul 3, 2015

I would like this feature but would like the strategy to take the Type and return a string for the Id.

PR #377 only lets you change the transformed id.

My use case is to combine class names for nested types but ignore namespaces. But you might want to use attributes etc to define your ids.

@gambrose
Copy link
Contributor

@domaindrivendev do you have a date when 5.2.2 is likely to be released?
I've been holding off using this feature until it lands in the NuGet feed.

@domaindrivendev
Copy link
Owner

Available in v5.2.2. See SchemaId option in the config API

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

No branches or pull requests

4 participants