microsoft / microsoft/typespec
Nested serialization
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
Related to this issue https://github.com/microsoft/typespec/issues/2479 but that one was only for `@query` and `@header`. So we might need a more general case.
There is a team that has a string property that is basically a json serialized string. Today you have to represent it as a string an let the end user serialize/deserialized themself.
```json
{
"id": "[/projects/sdk-project-dbsu5fc7xi3oi/catalogs/sdk-default-catalog/environmentDefinitions/sandbox](https://raw.githubusercontent.com/projects/sdk-project-dbsu5fc7xi3oi/catalogs/sdk-default-catalog/environmentDefinitions/sandbox)",
"name": "Sandbox",
"catalogName": "sdk-default-catalog",
"description": "Deploys an empty sandbox environment",
"parameters": [],
"parametersSchema": "{\"type\":\"object\"}",
"templatePath": "Environments/Sandbox/azuredeploy.json"
}
```
We could consider adding some support for this in this form
```tsp
model Body {
name: string;
catalogName: string;
description: string
// Use @encode to say how to serialize this property/type
@encode("application/json")
parametersSchema: Record
}
```
Contributor guide
Assessment
This issue has not been assessed yet.