Skip to content

Surface type hints in 'id' properties and parameters #1572

Closed
@bkoelman

Description

@bkoelman

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions