Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #4241
Closed
Open
Issue created Oct 23, 2019 by Administrator@rootContributor

[REQ] [csharp-netcore] Custom JsonSerializer needed

Created by: PeterTriebe

Is your feature request related to a problem? Please describe.

Lib: csharp-netcore

I want to do a "Patch" request to update some entries. For this reason its needed that "null" values are not serialized. If a property is not serialized it will be ignored from the service.

Describe the solution you'd like

To solve this i want to add a custom Json serializer. Inside this I'm able to say that null values will be ignored.

example how it worket after i changed the generated code:

        private RestRequest newRequest(
            HttpMethod method,
            String path,
            RequestOptions options,
            IReadableConfiguration configuration)
        {

....
            RestRequest request = new RestRequest(Method(method))
            {
                Resource = path,
                JsonSerializer = new CustomJsonCodec(new JsonSerializerSettings
                {
                  NullValueHandling = NullValueHandling.Ignore
                },configuration)
            };

But we want to make it more generic :-) The creation of this request is wrapped by the generated client. And there is actual no way to pass a custom Json serializer. I think its a good idea to pass a custon serializer together wirh the configuration. With this the client can configure what he want.

Describe alternatives you've considered

Its also possible to add some configurations like NullValueHandling = NullValueHandling.Ignore directly to the config. But i think thats not so suitable.

Additional context

Assignee
Assign to
Time tracking