microsoft / typespec

https://typespec.io/
MIT License
4.1k stars 194 forks source link

[Bug]: @info decorator failed to exclude unallow keys, it only allow fixed fields and start with "x-". #3887

Open skywing918 opened 1 month ago

skywing918 commented 1 month ago

Describe the bug

@info decorator failed to exclude unallow keys, it only allow fixed fields and start with "x-".

TSP

import "@typespec/openapi";
import "@typespec/openapi3";

using TypeSpec.OpenAPI;

@info({
  unallowKey: {},
})
@service({
  title: "My service",
})
namespace PetStore;

Actual Specification

openapi: 3.0.0
info:
  title: My service
  unallowKey: {}
  version: 0.0.0
tags: []
paths: {}
components: {}

Expected Specification

image

openapi: 3.0.0
info:
  title: My service
  version: 0.0.0
tags: []
paths: {}
components: {}

Reproduction

. git clone https://github.com/skywing918/typespec-workaround.git

  1. tsp compile unallowkey.tsp
  2. Open /tsp-output/@typespec/openapi3 to get the result

Checklist

timotheeguerin commented 1 month ago

This was something we didn't do exactly by design but changing it would be breaking. We have also considered removing the restriction of @extension to allow any keys to provide support for any things that we don't have a dedicated decorator for.

wanlwanl commented 1 month ago

For OAS3 emitter, at least we can improve it by outputing warning log when compiling tsp