-
Notifications
You must be signed in to change notification settings - Fork 243
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
OpenAPI Emitter: Response should respect @useRef #3601
Comments
p2 |
Playground Link |
In the package it("set external reference model", async () => {
const [{ Foo }, diagnostics] = await runner.compileAndDiagnose(`
@test @useRef("https://example.com/example.yml")
model Foo {
@statusCode
status: 200;
}
`);
expectDiagnosticEmpty(diagnostics);
strictEqual(getRef(runner.program, Foo), "https://example.com/example.yml");
}); So, there is no problem in setting the reference. The reference is set correctly. But, it is not written to the output. i.e. this test will error out: describe("openapi3: useRef decorator", () => {
it("adds a ref extension to a model", async () => {
const oapi = await openApiFor(`
@test @useRef("../common.json#/definitions/Foo")
model Foo {
@statusCode
status: 200;
name: string;
}
@get op get(): Foo;
`);
ok(oapi.paths["/"].get);
strictEqual(oapi.paths["/"].get.responses["200"]["$ref"], "../common.json#/definitions/Foo"); // <--- Will error out here
});
}); |
Per the requirement in [Issue 3601](#3601), the 'useRef' plugin must be respected and used correctly. This PR does that. **Before Changes**  **After Changes**  --------- Co-authored-by: Timothee Guerin <[email protected]>
Code Complete |
Closed by #3894 |
Should $ref be emitted without siblings? (specifically the built in response descriptions which can't be removed) Otherwise it'll cause this default spectral rule to fail https://docs.stoplight.io/docs/spectral/4dec24461f3af-open-api-rules#no-ref-siblings. Example
0.59.0-dev.4 Currently outputs
But should be
|
Clear and concise description of the problem
Should compile to:
Checklist
The text was updated successfully, but these errors were encountered: