Skip to content

converter: specification extensions are dropped from every object except Info #463

Description

@erraggy

Converting a document discards its specification extensions almost everywhere. Only info keeps them.

Reproduction

swagger: "2.0"
info:
  title: T
  version: "1.0.0"
  x-info-ext: kept?
x-root-ext: kept?
paths:
  /a:
    x-pathitem-ext: kept?
    get:
      operationId: a
      x-op-ext: kept?
      responses:
        "200":
          description: OK
          x-response-ext: kept?
        x-responses-ext: kept?
$ oastools convert -t 3.0.3 -q spec.yaml | grep "x-.*ext"
    x-info-ext: kept?

One of six survives. The root document, Path Item, Operation, Response and Responses Object extensions are all discarded.

Cause

The converters build fresh target values field by field and never copy Extra. For example convertOAS2OperationToOAS3 constructs a parser.Responses from Default and Codes alone, and nothing in converter/oas2_to_oas3.go or converter/oas3_to_oas2.go mentions Extra at all.

Why it matters

Extensions are how the specification says to carry vendor data, and plenty of real specs lean on them heavily for codegen hints, rate limits and gateway configuration. A conversion that silently drops them turns a lossless-looking operation into data loss, with nothing reported.

Worth deciding at implementation time whether a downgrade should report anything for extensions that cannot be represented, or simply carry them through, since extensions are version-neutral by design.

Scope

converter/oas2_to_oas3.go, converter/oas3_to_oas2.go, and any other site building a target value from scratch. A sweep is better than fixing the positions named above one at a time: the same omission will exist wherever a value is rebuilt field by field.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingoas2.0Issues related to Swagger (OpenAPI Specification 2.0)oas3.xIssues related to OpenAPI Specification versions 3+

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions