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

Support custom format-mappings via Key-Value configuration #438

Open
kirides opened this issue Aug 5, 2024 · 1 comment
Open

Support custom format-mappings via Key-Value configuration #438

kirides opened this issue Aug 5, 2024 · 1 comment
Assignees
Labels
enhancement New feature, bug fix, or request

Comments

@kirides
Copy link
Contributor

kirides commented Aug 5, 2024

Is your feature request related to a problem? Please describe.
Sending proprietary data types which have custom serialization attached to them is bothersome as we have to manually override the generated api contracts.

{
  "type": "string",
  "format": "date-time"
}

This will be mapped to DateTimeOffset for example.

Currently it's easy to override the "format" on the server side. But it's impossible to override the client generation to make use of the newly acquired information.

Describe the solution you'd like

{
  "type": "string",
  "format": "my-date-time"
}

Having a way to override string:my-date-time (imaginary syntax) generated output.
kind of like "dateType": "System.DateOnly" but for anything we need.

{
  "codeGeneratorSettings": {
    "typeOverrides": {
      "string:my-date-time": "Domain.Specific.DataType"
    }
  }
}

in Theory this should be doable by overriding how CSharpClientGeneratorSettings.CodeGeneratorSettings.TypeNameGenerator generates the type name

Describe alternatives you've considered
overriding the format to make the api return an object with a property of type "object", which then allows use to use "anyObjectType": "System.Text.Json.JsonElement" to manually deserialize the type.

But this requires us to copy the used JsonSerializationOptions everywhere.

Additional context
...

@kirides kirides added the enhancement New feature, bug fix, or request label Aug 5, 2024
@christianhelle
Copy link
Owner

I'm currently on holiday. I'll take a look at this in 2 weeks @kirides

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, bug fix, or request
Projects
None yet
Development

No branches or pull requests

2 participants