Skip to content

Payload examples for OAS #2047

Answered by NielsCo
BernieWhite asked this question in Q&A
Jun 12, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

I also didn't find any easy way to do this. Maybe write an Issue for this?

I have a suggestion for a very wonky workaround.
You could use an extension of OAS and then remove the "x" in a script.

Your example would be defined like this:

@extension("x-example", {id: "test", weight: 23123, color: "blue"})
model Widget {
  @key id: string;
  weight: int32;
  color: "red" | "blue";
}

Here is a playground-link
And then you would need to write a script that removes the "x-"
Obviously this isn't type-checked or anything as you can define anything you'd like to be an extension.

Type-Checked examples would be a very cool feature for TypeSpec IMHO.
If you're too busy to write the issue, let me know…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@BernieWhite
Comment options

Answer selected by BernieWhite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants