Skip to content

import - base64 content encoding should be imported as bytes #9150

@baywet

Description

@baywet

Clear and concise description of the problem

The following TypeSpec definition

model Foo {
  @encode("base64", string)
  b64_json?: bytes;
}

Leads to the follow OpenAPI 3.1/3.2 descriptions

openapi: 3.2.0
info:
  title: (title)
  version: 0.0.0
tags: []
paths: {}
components:
  schemas:
    Foo:
      type: object
      properties:
        b64_json:
          type: string
          contentEncoding: base64

And the following OpenAPI 3.0 description

openapi: 3.0.0
info:
  title: (title)
  version: 0.0.0
tags: []
paths: {}
components:
  schemas:
    Foo:
      type: object
      properties:
        b64_json:
          type: string
          format: base64

But importing those to TypeSpec leads to the following result in 3.1/3.2

model Foo {
  b64_json?: string;
}

And this result in 3.0

model Foo {
  @format("base64") b64_json?: string;
}

The import result looks correct for OpenAPI 3.0 due to the lack of support for contentEncoding. However the import in 3.1/3.2 should lead to a bytes type and an encode decorator.

Checklist

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Metadata

Metadata

Assignees

Labels

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

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions