-
Notifications
You must be signed in to change notification settings - Fork 349
Open
Labels
Description
Describe the bug
I wrap every return type in a Result alias, since it's not possible to define a global default error type, see #3082.
Since 1.7.0, this generates the following:
default:
description: Server error
content:
application/json:
schema:
anyOf:
- $ref: '#/components/schemas/DefaultError'
- $ref: '#/components/schemas/DefaultError'This is rejected by my OpenAPI codegen because of the duplicate indentical refs.
Here's what was generated on 1.6.0:
default:
description: An unexpected error response.
content:
application/json:
schema:
$ref: '#/components/schemas/DefaultError'The culprit seems to be @typespec/openapi3 v1.7.0 from what I can tell.
Reproduction
import "@typespec/http";
import "@typespec/openapi";
import "@typespec/openapi3";
using TypeSpec.Http;
using TypeSpec.OpenAPI;
@service(#{ title: "Repro" })
namespace Repro;
@error
model Error<Status> {
@statusCode _: Status;
message: string;
}
@error
@defaultResponse
model DefaultError is Error<500>;
alias Result<T> = T | DefaultError;
model Thing {
id: string;
name: string;
}
@route("/things")
namespace Things {
@get op list(): Result<Thing[]>;
}With the following versions:
"@typespec/compiler": "1.7.0",
"@typespec/http": "1.7.0",
"@typespec/openapi": "1.7.0",
"@typespec/openapi3": "1.7.0"
This generates the above with tsp compile ./main.tsp. Changing to openapi3@1.6.0 generates the correct version.
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.
Reactions are currently unavailable