Skip to content

Schema type badge does not show [TypeName] for non-object schemas with title (e.g. enums show as plain "string" instead of "string [OrderStatus]") #1308

Description

@augustoavci

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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