microsoft / microsoft/typespec
[Bug]: OpenAPI 3.2 import incorrectly applies `#deprecated`
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
### Describe the bug
This may be a problem with other contexts or OpenAPI versions, but I found this while debugging examples for the 1.10 release notes.
When importing a schema that has `$ref` with sibling keywords, if one of the sibling keywords is `deprecated`, we don't emit a deprecation message or a newline, which makes the generated TypeSpec unable to parse.
We need to provide a message for the `#deprecated` directive and split it onto a new line.
### Reproduction
Try to import:
```yaml
openapi: 3.2.0
info:
title: Minimal import deprecated reproduction
version: 1.0.0
paths:
/test:
get:
parameters:
- name: order
in: query
schema:
$ref: "#/components/schemas/OrderEnum"
default: desc
deprecated: true
responses:
"200":
description: OK
components:
schemas:
OrderEnum:
type: string
enum:
- asc
- desc
```
Result (unformatted):
```tsp
import "@typespec/http";
import "@typespec/openapi";
import "@typespec/openapi3";
using Http;
using OpenAPI;
@service(#{
title: "Minimal import deprecated reproduction"
})
@info(#{version: "1.0.0"})
namespace Minimalimportdeprecatedreproduction;
enum OrderEnum {
"asc",
"desc",
}
@route("/test") @get
// FIXME: Open API operation 'GET /test' is missing an operationId. Generated: 'get_test'
op get_test(#deprecated @query(#{explode: true}) order?: OrderEnum = OrderEnum.desc): OkResponse;
```
### Checklist
- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions).
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
Contributor guide
Assessment
This issue has not been assessed yet.