Skip to content

[Bug]: tsp-openapi generates invalid tagMetadata objects #9147

@sensiblewood-ozone

Description

@sensiblewood-ozone

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingopenapi3:converterIssues for @typespec/openapi3 openapi to typespec convertertriaged:core

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions