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

openapi3 (v0.51.0): duplicate-type-name error when sharing type across routes w/multipart-form-data #2751

Closed
trrwilson opened this issue Dec 13, 2023 · 1 comment
Assignees
Labels
bug Something isn't working triaged:core

Comments

@trrwilson
Copy link
Member

[TypeSpec playground link to repro]

Using a custom type (tested: both model and enum) in a route that sets its content-type header to multipart/form-data appears to jealously guard against any other route using that type -- an attempt to do so results in

error @typespec/openapi/duplicate-type-name: Duplicate type name: 'MyModel'. Check @friendlyName decorators and overlap with types in TypeSpec or service namespace.

Omitting overridden use of content-type or setting to another value like text/plain or application/octet-stream doesn't encounter the issue, so it appears unique to multipart/form-data.

  @get listMyThings(input: MyRequestModel): string;
  @post uploadMyThings(
    // OK if next line commented out or using another type like text/plain
    @header contentType: "multipart/form-data";
    input: MyRequestModel): string;

Thanks!

@timotheeguerin
Copy link
Member

This to be some issue with implicit body with the repro(if you add @body for the input everything is working fine, but might not be limited to that

@timotheeguerin timotheeguerin self-assigned this Dec 13, 2023
@timotheeguerin timotheeguerin added the bug Something isn't working label Dec 13, 2023
@timotheeguerin timotheeguerin added this to the [2024] January milestone Dec 13, 2023
timotheeguerin added a commit that referenced this issue Dec 13, 2023
…used in multipart implicit body and json body. (#2752)

fix #2751

Problem was when we reduce the context it is a patch not a replace so if
we delete the contentType to have the default handling then it would
keep the previous value instead of actually removing it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triaged:core
Projects
None yet
Development

No branches or pull requests

2 participants