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

Add setting to change the URI type in generated clients #2573

Open
Mystikweb opened this issue Dec 9, 2019 · 5 comments
Open

Add setting to change the URI type in generated clients #2573

Mystikweb opened this issue Dec 9, 2019 · 5 comments

Comments

@Mystikweb
Copy link

I have a C# DTO model for input in my API that takes a string with the DataType annotation for a URL.

[DataType(DataType.Url)]
public string Url { get; set; }

I am using the generated C# client in Razor pages and would have expected the client to use the same sort of annotations but instead I am seeing it come in as a System.Uri.

Is it possible that I missed something in the settings?

@RicoSuter
Copy link
Owner

RicoSuter commented Dec 11, 2019

Currently there is no setting to change the generated uri type via cli/nswagstudio.

You could use the packages to generate and overload the type resolver method.

But it makes sense to add a setting

  • Needs to be added to NJsonSchema
  • and exposed via cli and the ui

@RicoSuter RicoSuter changed the title NSwag Studio CSharp Client URL DataType Configuration Add setting to change the URI type in generated clients Apr 7, 2020
@fallaciousreasoning
Copy link

Just wanted to check if there's been any progress on this - and if not, would you be interested in accepting a PR for this?

@jeremyVignelles
Copy link
Collaborator

No progress AFAIK, but that would add complexity to the template, which is already bloated. Not sure if we should add the option, but you could try to make a PR

@RicoSuter
Copy link
Owner

I'm fine adding this config similar to the array type configs.

add complexity to the template

It would only be a C# level config, would not need any template changes (no additional complexity there).

@herrahlstrom
Copy link

Hi,

I made a pull request that should solve this issue in NJsonSchema
RicoSuter/NJsonSchema#1567

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

5 participants