Currently, all id parameters are declared as type: string in the emitted openapi.json. Adding type hints like format: uuid enables client generators to produce more specific types.
Implementation notes
Because all id properties are declared as string in the generic models, we need a custom schema generator that calls the default schema generator on the actual ID type in the resource graph, ie:
OpenApiSchema idSchema = _defaultSchemaGenerator.GenerateSchema(identityClrType, schemaRepository);
fullSchemaForDerivedType.Properties[JsonApiPropertyName.Id].Format = idSchema.Format;
// Possibly take more fields, but Type needs to remain `string`.
The custom schema generator needs to be called from all places where IDs are used, which includes resource objects, resource identifier objects, and action method parameters.
For atomic operations, the same applies to lid. The replacement additionally needs to run on relationship identifier objects (ref).
Currently, all
id
parameters are declared astype: string
in the emittedopenapi.json
. Adding type hints likeformat: uuid
enables client generators to produce more specific types.Implementation notes
Because all
id
properties are declared asstring
in the generic models, we need a custom schema generator that calls the default schema generator on the actual ID type in the resource graph, ie:The custom schema generator needs to be called from all places where IDs are used, which includes resource objects, resource identifier objects, and action method parameters.
For atomic operations, the same applies to
lid
. The replacement additionally needs to run on relationship identifier objects (ref
).