Skip to content

Add support for list with encode of string #8874

@lmazuel

Description

@lmazuel

Clear and concise description of the problem

Short version:

model MyModel {
  @encode(string, ",")
  terms: string[];
}

would match this JSON:

{
  "synomyms": "a,b,c"
}

and produce SDK like:

class Data:
   synonyms: List[str]

Which will tell the serializer deserializer to use csv, for instance a,b,c. Delimiter is the second parameter. We may decide to accept it only on list of strings for now (refuse int[])

Kwown separator: \n, | and ,

Checklist

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Metadata

Metadata

Assignees

Labels

compiler:coreIssues for @typespec/compilerdesign:acceptedProposal for design has been discussed and accepted.triaged:core

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions