Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

The OpenAPI-to-TypeSpec converter generated invalid @tagMetadata("tag") decorators for tags lacking descriptions, causing compilation errors since the decorator requires exactly 2 arguments.

Changes

  • Modified generate-tags.ts: Emit @tagMetadata("tag", #{}) with empty metadata object instead of single-argument form when tag has no description or externalDocs
  • Added test case: tag-without-description spec validates conversion of tags without metadata
  • Updated snapshot: playground-http-service now correctly generates two-argument form

Example

OpenAPI input:

tags:
  - name: consents

Generated TypeSpec (before):

@tagMetadata("consents")  // ❌ error: Expected 2 arguments, but got 1

Generated TypeSpec (after):

@tagMetadata("consents", #{})  // ✅ compiles successfully

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/astro.js build sh -c ebsite/src/content/docs/docs/emitters/openapi3/reference node pec/node_modules/.bin/sh warn-as-error --sh . .0/bin/sh node /hom�� astro check --minimumFailingSeverity hint && astro build node .0_tmp_3586/node_modules/pnpm/dist/node-gyp-bin/node --no-emit sh _modules/pnpm/ditsx ./.scripts/regen-compiler-docs.ts sh (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: tsp-openapi generates invalid tagMetadata objects</issue_title>
<issue_description>### Describe the bug

In OpenAPI 3.0 to 3.1 (pre-3.2 changes) a Tag description is optional: https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-18

When running tsp-openapi at v1.5.0 you get the following when you have a Tag with no description:

@tagMetadata("consents")

Which tsp compile then complains about:

TypeSpec compiler v1.5.0

× Compiling
Diagnostics were reported during compilation:

<redacted>:76:1 - error invalid-argument-count: Expected 2 arguments, but got 1.
> 76 | @tagMetadata("consents")
     | ^^^^^^^^^^^^^^^^^^^^^^^^

Found 1 error.

Suggest changing tsp-openapi to generate the following:

@tagMetadata("consents", #{})

Which is semantically correct and allows the description to continue not existing.

Reproduction

Copy this bad boy into an OpenAPI document, add it to an operation, and run tsp-openapi:

tags:
- name: consents

And you'll see the result.

Checklist

<agent_instructions>Change the typespec output from the tsp-openapi copnverter to emit @tagMetadata("tag-name", #{}) rather than @tagMetadata("tag-name") when there is no additional metadata in the tag in the source OpenApi doc.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ription

Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix tsp-openapi to generate valid tagMetadata objects Dec 8, 2025
Copilot AI requested a review from markcowl December 8, 2025 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants