Describe the bug
When Swagger mappings are generated for a value object backed by int, Vogen emits JsonSchemaType.Number.
Given:
[ValueObject<int>]
public readonly partial record struct MyCustomId;
The generated mapping is:
global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions
.MapType<global::MyCustomId>(
o,
() => new global::Microsoft.OpenApi.OpenApiSchema
{
Type = global::Microsoft.OpenApi.JsonSchemaType.Number,
Format = "int32"
});
However, an int-backed value object should be represented as an OpenAPI integer:
global::Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions
.MapType<global::MyCustomId>(
o,
() => new global::Microsoft.OpenApi.OpenApiSchema
{
Type = global::Microsoft.OpenApi.JsonSchemaType.Integer,
Format = "int32"
});
Impact
The resulting OpenAPI schema does not correctly describe the underlying value. Client generators may treat the value as a generic numeric or floating-point type instead of an integer.
Environment
- Vogen: 8.0.7
- Target framework: .NET 10
Steps to reproduce
just enable openApiSchemaCustomizations: OpenApiSchemaCustomizations.GenerateSwashbuckleMappingExtensionMethod
Expected behaviour
Value objects backed by integral types should use JsonSchemaType.Integer, with the appropriate format such as int32 or int64.
Describe the bug
When Swagger mappings are generated for a value object backed by int, Vogen emits JsonSchemaType.Number.
Given:
The generated mapping is:
However, an int-backed value object should be represented as an OpenAPI integer:
Impact
The resulting OpenAPI schema does not correctly describe the underlying value. Client generators may treat the value as a generic numeric or floating-point type instead of an integer.
Environment
Steps to reproduce
just enable openApiSchemaCustomizations: OpenApiSchemaCustomizations.GenerateSwashbuckleMappingExtensionMethod
Expected behaviour
Value objects backed by integral types should use JsonSchemaType.Integer, with the appropriate format such as int32 or int64.