Skip to content

fix(openapi3): remove stray items when array is encoded to a scalar#11203

Draft
timotheeguerin wants to merge 1 commit into
mainfrom
timotheeguerin/openapi3-fix-9216
Draft

fix(openapi3): remove stray items when array is encoded to a scalar#11203
timotheeguerin wants to merge 1 commit into
mainfrom
timotheeguerin/openapi3-fix-9216

Conversation

@timotheeguerin

Copy link
Copy Markdown
Member

Fixes #9216

Problem

For a property whose array type is encoded to a scalar via @encode (e.g. ArrayEncoding.commaDelimited), the emitter overrode the schema type from array to the scalar but left a stray items section behind:

"prop": { "type": "string", "items": { "type": "string" }, "format": "ArrayEncoding.commaDelimited" }

Fix

In applyEncoding, when the encoded type is no longer an array, items/prefixItems are removed. The format value is intentionally left unchanged (out of scope).

Tests

Added a test asserting no items is emitted for a @encode(ArrayEncoding.commaDelimited) array property.

When @encode changes an array property's schema type to a scalar (e.g. ArrayEncoding.commaDelimited), the leftover items schema is now removed.

Fixes #9216
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:openapi3 Issues for @typespec/openapi3 emitter label Jul 8, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/openapi3@11203

commit: 16b15a2

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/openapi3
Show changes

@typespec/openapi3 - fix ✏️

Fix stray items being emitted on a property whose array type is encoded to a scalar via @encode (e.g. ArrayEncoding.commaDelimited).

@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

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

Labels

emitter:openapi3 Issues for @typespec/openapi3 emitter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

additional items section for properties with array type but array encoding

1 participant