Description
When a named enum (or any non-object schema) has a title set, the type badge renders the bare primitive type (e.g. string) without appending [TypeName].
Object schemas with a title already display correctly as object [TypeName], this behaviour is missing for other types.
Steps to reproduce
Expand the Order schema in the playground with this spec and look at the
status property type badge.
asyncapi: 3.0.0
info:
title: Enum Display Test
version: 1.0.0
components:
schemas:
OrderStatus:
type: string
title: OrderStatus
enum: [OPEN, IN_PROGRESS, CLOSED]
Order:
type: object
properties:
status:
$ref: '#/components/schemas/OrderStatus'
Expected: string [OrderStatus]
Actual: string
Root cause
In library/src/helpers/schema.ts, toSchemaType() only appends [title]
when type === 'object':
if (type === 'object' && schema.title()) {
type += ' [' + schema.title() + ']';
}
Suggested fix
if (schema.title() && type !== schema.title()) {
type += ' [' + schema.title() + ']';
}
The type !== schema.title() guard prevents degenerate output like string [string]. This is consistent with existing object behaviour, it simply extends it to all named schema types.
Description
When a named enum (or any non-object schema) has a
titleset, the type badge renders the bare primitive type (e.g.string) without appending[TypeName].Object schemas with a
titlealready display correctly asobject [TypeName], this behaviour is missing for other types.Steps to reproduce
Expand the Order schema in the playground with this spec and look at the
statusproperty type badge.Expected:
string [OrderStatus]Actual:
stringRoot cause
In
library/src/helpers/schema.ts,toSchemaType()only appends[title]when
type === 'object':if (type === 'object' && schema.title()) {
type += ' [' + schema.title() + ']';
}
Suggested fix
if (schema.title() && type !== schema.title()) {
type += ' [' + schema.title() + ']';
}
The
type !== schema.title()guard prevents degenerate output likestring [string]. This is consistent with existing object behaviour, it simply extends it to all named schema types.