Skip to content

[Bug]: Error using multiple examples #7623

Open
@moacirandretti

Description

@moacirandretti

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions