[typespec-autorest] if the discriminator property has `@header`, an invalid swagger is generated
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 90
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 161
Description
First of all, could discriminator be something else than body property, such as a header/query/path?
When I wrote such typespec, I get no errors at all.
[Playground for Azure case](https://cadlplayground.z22.web.core.windows.net/cadl-azure/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CtIZcmVzdNUZdmVyc2lvbmluZ8wfYXp1cmUtdG9vbHMvyCstxhVjb3JlIjsKCnVzaW5nIEh0dHA7xwxSZXN0yAxWyVfIEkHEPi5Db3Jl0hIuVHJhaXRzOwoKQHVzZUF1dGgoCiAgQXBpS2V5xA48xgtMb2NhdGlvbi5oZWFkZXIsICJhcGkta2V5Ij4gfCBPxCoyxS9bCiAgICB7xQYgIOQAwTrHH0Zsb3dUeXBlLmltcGxpY2l0LMclYXV0aG9yaXrFYVVybDogIuQBTXM6Ly9sb2dpbi5jb250b3NvLmNvbS9jb21tb24vb8Q1Mi92Mi4wL8hAZSLIUnNjb3BlczogW8lJd2lkZ2V0zUouZGVmYXVsdCJdxjd9CiAgXT4KKQpAc2VydmljZSgjeyB0aXRsZTogIkPGOSBXxUggTWFuYWdlciIgfccvZXLkATcie2VuZHBvaW50fcdy5QCT0D5BUElzxRnmAScvKiogClN1cOQCAWVkyCVT5gCFcyDIU3MgKHByb3RvY29sIGFuZCBob3N0bmFtZSwgZm9yIGV4YW1wbGU6CukA8mVzdHVzLmFwaS7yAP0pLgogKi%2FFfshfOiBzdHJpbmfkAJh95AEG5wKfZWQo5wC%2FLuYAmucA%2FC7nAmhzKQrkAIZzcGFjZSDVKjsKCuQA41RoySDvAUcg5wFxIMdzLuQAnGVudW3oAsxz5QEqxEXHESAyMDIyLTA4LTMxxCwgIOQCvURlcGVuZGVuY3ko6wLgyEMudjFfMF9QcmV2aWV3XzIpCiAgYMlGMGAsCn0KCkByb3V0ZSgiL3TkA7QpCm9wIMQKKEBib2R5Um9vdCDECTogQmFzZSk6IHZvaWTkAzlkaXNjcmltaW5hdG9yKCJraW5kIikKbW9kZWzFK%2BUAvkDmAzoKICDEIOgBbjvEd8YqQSBleHRlbmRz2jQiYSI7CiAgYT%2FMPw%3D%3D&e=%40azure-tools%2Ftypespec-autorest&options=%7B%22linterRuleSet%22%3A%7B%22extends%22%3A%5B%22%40azure-tools%2Ftypespec-azure-rulesets%2Fdata-plane%22%5D%7D%7D): this produces invalid swagger.
[Playground for unbranded](https://typespec.io/playground/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7DQoNCnVzaW5nIFR5cGVTcGVjLkh0dHDFGEBkaXNjcmltaW5hdG9yKCJraW5kIikNCm1vZGVsIEJhc2Ugew0KICBAaGVhZGVyxAvEIzogc3RyaW5nOw0KfcRHxi9BIGV4dGVuZHPcOSJh5ACSxTZvcCB0ZXN0KEBib2R5Um9vdCDECTrFPik6IHZvaWQ7DQo%3D&e=%40typespec%2Fopenapi3&options=%7B%7D)
If this is invalid typespec, we should prevent such syntax by introducing compilation errors.
If this is valid typespec, we should fix the typespec-autorest so that it could produce correct swagger.
Contributor guide
Research direction
Reproduce the Azure and unbranded examples in the linked TypeSpec playgrounds, using @azure-tools/typespec-autorest and @typespec/openapi3. Inspect the generator and validation entry points for discriminator properties marked with @header; done means either compilation rejects the syntax or the generated Swagger is valid and represents the discriminator correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100