Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cadl-lang/openapi",
"comment": "`@defaultResponse` set status code for model",
"type": "minor"
}
],
"packageName": "@cadl-lang/openapi"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cadl-lang/openapi3",
"comment": "Moved http response interpretation to @cadl-lang/rest library.",
"type": "minor"
}
],
"packageName": "@cadl-lang/openapi3"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cadl-lang/rest",
"comment": "Add logic to interpret the http responses.",
"type": "minor"
}
],
"packageName": "@cadl-lang/rest"
}
2 changes: 2 additions & 0 deletions packages/openapi/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
validateDecoratorParamType,
validateDecoratorTarget,
} from "@cadl-lang/compiler";
import { http } from "@cadl-lang/rest";
import { reportDiagnostic } from "./lib.js";

const operationIdsKey = Symbol();
Expand Down Expand Up @@ -64,6 +65,7 @@ export function $defaultResponse({ program }: DecoratorContext, entity: Type) {
if (!validateDecoratorTarget(program, entity, "@defaultResponse", "Model")) {
return;
}
http.setStatusCode(program, entity, ["*"]);
program.stateSet(defaultResponseKey).add(entity);
}

Expand Down
18 changes: 0 additions & 18 deletions packages/openapi3/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,12 @@ export const libDef = {
default: "Duplicate @body declarations on response type",
},
},
"duplicate-response": {
severity: "error",
messages: {
default: paramMessage`Multiple return types for content type ${"contentType"} and status code ${"statusCode"}`,
},
},
"duplicate-header": {
severity: "error",
messages: {
default: paramMessage`The header ${"header"} is defined across multiple content types`,
},
},
"content-type-ignored": {
severity: "warning",
messages: {
default: "content-type header ignored because return type has no body",
},
},
"content-type-string": {
severity: "error",
messages: {
default: "contentType parameter must be a string literal or union of string literals",
},
},
"status-code-in-default-response": {
severity: "error",
messages: {
Expand Down
Loading