Open
Description
Describe the bug
Hey Devs!
I'm having some troubles to provide multiples examples at the same time on Typespe.
Even I provide multiple examples, when typespec emmit the doc to YAML (openapi 3), only the last example shows.
I've tried to follow doc instructions, but no success:
@example(
#{ name: "Rex", age: 8, bark: true },
#{ title: "With optional properties", description: "Example where the pet barks" }
)
For the last test, I've tried to create multiples examples using the sample of playground and same error.
@example(#{
id: "123",
weight: 123,
color: "red"
})
@example(#{
id: "999",
weight: 800,
color: "blue"
})
model Widget {
@visibility(Lifecycle.Read)
id: string;
weight: int32;
color: "red" | "blue";
}
Reproduction
Link of my attempt on playground.
Version used: 1.1.0
Code used:
import "@typespec/http";
using Http;
@service(#{ title: "Widget Service" })
namespace DemoService;
@example(
#{ id: "123", weight: 50, color: "red"},
#{ id: "123", weight: 50, color: "blue" }
)
model Widget {
@visibility(Lifecycle.Read)
id: string;
weight: int32;
color: "red" | "blue";
}
@error
model Error {
code: int32;
message: string;
}
@route("/widgets")
@tag("Widgets")
interface Widgets {
/** List widgets */
@get list(): Widget[] | Error;
/** Read widgets */
@get read(@path id: Widget.id): Widget | Error;
/** Create a widget */
@post create(@body widget: Widget): Widget | Error;
/** Update a widget */
@patch update(@path id: Widget.id, @body widget: MergePatchUpdate<Widget>): Widget | Error;
/** Delete a widget */
@delete delete(@path id: Widget.id): void | Error;
/** Analyze a widget */
@route("{id}/analyze") @post analyze(@path id: Widget.id): string | Error;
}
Checklist
- Follow our Code of Conduct
- Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.