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

Closed

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

  1. github-actions commented on Jun 30, 2026

    @github-actions
    Contributor

    Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
    Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

  2. Jannik-cmyk commented on Aug 7, 2026

    @Jannik-cmyk

    Hi, I rechecked the current master branch and the relevant toSchemaType() code path is still unchanged, so this issue still applies.

    I have a focused fix and regression tests prepared. The intended scope is to:

    • append [title] to named scalar/inferred-enum and array schema type badges,
    • avoid duplicate output when the rendered type already matches the title,
    • preserve the existing early-return behavior for union types and oneOf/anyOf/allOf composition rather than broadening this change into a larger formatting refactor,
    • add both helper-level coverage and a component-level assertion for the visible badge.

    Would maintainers approve this scope and be okay with me opening a PR? I’ll run the full repository test/lint checks before submitting it.

  3. AceTheCreator commented on Sep 16, 2026

    @AceTheCreator
    Member

    Hi, I rechecked the current master branch and the relevant toSchemaType() code path is still unchanged, so this issue still applies.

    I have a focused fix and regression tests prepared. The intended scope is to:

    • append [title] to named scalar/inferred-enum and array schema type badges,
    • avoid duplicate output when the rendered type already matches the title,
    • preserve the existing early-return behavior for union types and oneOf/anyOf/allOf composition rather than broadening this change into a larger formatting refactor,
    • add both helper-level coverage and a component-level assertion for the visible badge.

    Would maintainers approve this scope and be okay with me opening a PR? I’ll run the full repository test/lint checks before submitting it.

    Feel free to open a PR

  4. MaybeSomeone-arc18 commented on Sep 22, 2026

    @MaybeSomeone-arc18

    I reproduced this and have a small fix ready. It extends the existing title suffix behavior to non-object schemas while avoiding duplicate output when the title matches the inferred type. I also added regression tests for a titled string schema and the duplicate-title case. May I take this issue and open the PR?

  5. viky-01 commented on Oct 6, 2026

    @viky-01
    Contributor

    Hi @AceTheCreator! As discussed, I've opened PR #1361 resolving this issue. It appends [schema.title()] to the type badge for non-object schemas (such as named enums and scalars) while preventing duplicate output when the title matches the inferred type. Full helper unit tests and component tests are included. Ready for review!

  6. asyncapi-bot commented on Oct 16, 2026

    @asyncapi-bot
    Contributor

    🎉 This issue has been resolved in version 3.2.2 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions