Skip to content

[Bug]: OpenAPI 3.2 import incorrectly applies #deprecated #10043

@witemple-msft

Description

@witemple-msft

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:

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):

  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi3:converterIssues for @typespec/openapi3 openapi to typespec convertertriaged:core

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions