RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.82k stars 1.3k forks source link

validating openapi document on controller generation (or client) #4235

Open shlomo-margalit opened 2 years ago

shlomo-margalit commented 2 years ago

I am using operation.ExtensionData in the Controller.liquid template to generate some extra code. (see https://github.com/RicoSuter/NSwag/issues/1436 for more details).

if an openapi operation contains the same extension twice, nswag will just set the value to the last entry.

for example when the document contains: /action get: x-property: a x-property: b

the liquid file will get the property value as "b".

when using https://editor.swagger.io/ to edit the file, it flags the duplicate as error. but nswag doesn't throw an exception on this.

while debugging nswag I noticed that YamlDotNet already returns just the last entry, without doing any validations. i'm not sure if this is valid in Yaml or not (maybe it's just invalid in openapi).

is there a plan to validate the openapi document? if not, I will have to find another tool to do this.

shlomo-margalit commented 2 years ago

I found the same issue in the YamlDotNet repository: https://github.com/aaubry/YamlDotNet/issues/536