Importing the following OpenAPI description
openapi: 3.0.0
info:
title: (title)
version: 0.0.0
tags: []
paths:
/:
get:
operationId: myOp
parameters: []
responses:
'200':
description: The request has succeeded.
4XX:
description: Client error
content:
application/json:
schema:
$ref: '#/components/schemas/MyError'
components:
schemas:
MyError:
type: object
Results in the following TypeSpec definition
import "@typespec/http";
using TypeSpec.Http;
model MyError {
}
model MyResponse {
}
op myOp (): MyResponse | {
@maxValue(499)
@minValue(400)
@statusCode
statusCode: int32;
@body
error: MyError;
};
Note the absence of @error decorator on the MyError model.
This is also a problem without ranges
openapi: 3.0.0
info:
title: (title)
version: 0.0.0
tags: []
paths:
/:
get:
operationId: myOp
parameters: []
responses:
'200':
description: The request has succeeded.
'401':
description: Access is unauthorized.
content:
application/json:
schema:
$ref: '#/components/schemas/MyError'
components:
schemas:
MyError:
type: object
The import tool should add the error decorator when a model is used as the response body for an error response (specific code between 400 and 599 included, 400 to 499 or 500 to 599 ranges, etc...)
Importing the following OpenAPI description
Results in the following TypeSpec definition
Note the absence of
@errordecorator on the MyError model.This is also a problem without ranges
The import tool should add the error decorator when a model is used as the response body for an error response (specific code between 400 and 599 included, 400 to 499 or 500 to 599 ranges, etc...)