Skip to content

[ASPNETCORE] Nullable custom valuetypes #22346

@leonluc-dev

Description

@leonluc-dev

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions