microsoft / microsoft/typespec

Nested serialization

Open
#3,005 0 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

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

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.