Open
Description
Describe the bug
{The problematic object} failed to {describe the problem}.
TSP
import "@typespec/http";
import "@typespec/openapi";
using TypeSpec.Http;
using OpenAPI;
@service({
title: "Style and Explode"
})
namespace StyleAndExplode;
model Widget {
@visibility("read")
id: string;
weight?: int32;
color?: "red" | "blue";
}
// TypeSpec supports certain combinations of the style and explode
// fields of parameter objects.
@tag("Widgets")
@route("/widgets")
namespace Widgets {
// Header parameters
@post op create(
// has no style or explode
@header apiVersion?: string,
// has style: simple and no explode
@header({format: "simple"}) xMsClientRequestId?: string,
): Widget;
}
Actual Specification
https://typespec.io/docs/getting-started/typespec-for-openapi-dev#openapi-v3
openapi: 3.0.0
info:
title: Style and Explode
version: 0.0.0
tags:
- name: Widgets
paths:
/widgets:
post:
tags:
- Widgets
operationId: Widgets_create
parameters:
- name: api-version
in: header
required: false
schema:
type: string
- name: x-ms-client-request-id
in: header
required: false
schema:
type: string
style: simple
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Widget'
components:
schemas:
Widget:
type: object
required:
- id
properties:
id:
type: string
readOnly: true
weight:
type: integer
format: int32
color:
type: string
enum:
- red
- blue
Expected Specification
https://spec.openapis.org/oas/v3.0.0#parameter-object
Reproduction
git clone https://github.com/skywing918/typespec-workaround.git
tsp compile parameter.tsp
- Open
/tsp-output/@typespec/openapi3
to get the result
Checklist
- Follow our Code of Conduct
- Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.