typespec icon indicating copy to clipboard operation
typespec copied to clipboard

openapi/json-schema - `@extension` alignment - emit schemas

Open chrisradek opened this issue 11 months ago • 2 comments

This issue tracks updating the @typespec/openapi @extension decorator to emit passed in Types as Open API schemas, similar to how @typespec/json-schema will emit JSON Schemas for passed in types.

For example:

@OpenAPI.extension("x-foo", { foo: true })
model Foo {}

will generate a schema since { foo: true } is a Type.

Foo:
  type: object
  x-foo:
    type: object
    required:
      - foo
    properties:
      foo:
        type: boolean
        enum:
          - true

This can be considered a breaking change for anyone passing in a model or tuple expression into @OpenAPI.extension. To migrate, users will need to use Value kinds instead.

For example, { foo: true } would be updated to #{ foo: true }.

This should not be completed until after #6076 has been included in a release.

chrisradek avatar Feb 20 '25 07:02 chrisradek

est: 5

markcowl avatar Feb 24 '25 19:02 markcowl

Moving to Post 1.0. Tentative sprint: July 25.

allenjzhang avatar Mar 14 '25 00:03 allenjzhang

In addition, as off version 1.3.0, the import process will keep those double quotes, which leads to an invalid TypeSpec project.

So

      x-foo:
        name: The container file object

Leads to

@extension("x-oaiMeta", {"name":"The admin API key object"})

Which should be

@extension("x-oaiMeta", #{name:"The admin API key object"})

Or as a diff

-@extension("x-oaiMeta", {"name":"The admin API key object"})
+@extension("x-oaiMeta", #{name:"The admin API key object"})

baywet avatar Aug 12 '25 15:08 baywet