Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operation example should resolve example for multiple responses correctly #4033

Closed
timotheeguerin opened this issue Jul 26, 2024 · 0 comments · Fixed by #4046
Closed

Operation example should resolve example for multiple responses correctly #4033

timotheeguerin opened this issue Jul 26, 2024 · 0 comments · Fixed by #4046
Labels
bug Something isn't working emitter:openapi3 Issues for @typespec/openapi3 emitter triaged:core

Comments

@timotheeguerin
Copy link
Member

timotheeguerin commented Jul 26, 2024

Playground Link

import "@typespec/http";

using TypeSpec.Http;

model UserFields {
  name: string;
}

@opExample(
  #{ returnType: #{ statusCode: 200, user: #[#{ name: "abc" }] } },
  #{ title: "Example 1" }
)
@opExample(
  #{ returnType: #{ statusCode: 404, error: "No user with this name" } },
  #{ title: "Not found" }
)
op list(): {
  @statusCode statusCode: 200;
  @bodyRoot user: UserFields[];
} | (NotFoundResponse & {
  error: string;
});

Result in this both both responses

examples:
                Not found:
                  summary: Not found
                  value: {}
                Example 1:
                  summary: Example 1
                  value: {}

There is 2 issues:

  1. the value are not actually populated
  2. only the matching response should have the example
@timotheeguerin timotheeguerin added bug Something isn't working emitter:openapi3 Issues for @typespec/openapi3 emitter labels Jul 26, 2024
@markcowl markcowl added this to the [2024] September milestone Jul 29, 2024
github-merge-queue bot pushed a commit that referenced this issue Aug 5, 2024
fix #4033

A few issues:
- Example being empty 
- Example duplicating for all responses instead of mapping to the right
one

---------

Co-authored-by: Christopher Radek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working emitter:openapi3 Issues for @typespec/openapi3 emitter triaged:core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants