microsoft / microsoft/typespec

Seralize operation parameters as json(or other media type)

Open
#2,479 2 comments 1 reaction 0 assignees View on GitHub
design:needed triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

This is not something we supported in autorest but this is something available in openapi

See autorest issue where someone ask for support https://github.com/Azure/autorest/issues/4773
```json
{
"summary": "Return list of Scripts",
"parameters": [
{
"name": "ScriptQuery",
"in": "header",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ScriptQuery"
}
}
}
}
]
}

```

From the openapi3 docs

> Other Serialization Methods
style and explode cover the most common serialization methods, but not all. For more complex scenarios (for example, a JSON-formatted object in the query string), you can use the content keyword and specify the media type that defines the serialization format. For more information, see [schema vs content](https://swagger.io/docs/specification/describing-parameters/#schema-vs-content).

Maybe could have something like that
```tsp
@encode("application/json")
@query
data: ComplexObject;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.