OpenAPITools / OpenAPITools/openapi-generator
[ASPNETCORE] Nullable custom valuetypes
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Currently I have a custom type declared as such:
"typeMappings": {
"string+my-custom-value-type": "MyCustomValueType"
}
MyCustomValueType is a struct (e.g. value type).
In non-nullable context the type is generated as expected:
"exampleProperty": {
"type": "string",
"format": "my-custom-value-type"
}
public MyCustomValueType ExampleProperty { get; set; }
But whenever I define a property as nullable the generated property is missing the explicit ? (nullable) suffix required for value types.
OpenAPI spec:
"exampleProperty": {
"type": "string",
"format": "my-custom-value-type",
"nullable": true
}
public MyCustomValueType ExampleProperty { get; set; }
Expected:
public MyCustomValueType? ExampleProperty { get; set; }
Is there a way to tell the (aspnetcore) generator to treat a custom type as a value type?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the ASP.NET Core generation with the supplied typeMappings and OpenAPI schema, then inspect the generator's handling of nullable custom types. The issue names no source files or tests, so locate the type-mapping and nullable-property generation entry points. Done means a nullable custom struct is emitted with the explicit ? suffix while the non-nullable case remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, openapi
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100