Open genek96 opened 7 months ago
See https://github.com/microsoft/typespec/issues/3549#issuecomment-2166501680. Setting additionalProperties: false
across all models would basically muddy intended semantics of extends
syntax. It would have to be a decorator, and it would probably need a fair amount of build time error handling to prevent confusing situations.
However unevaluatedProperties
probably makes sense as a schema-gen-wide config option.
Clear and concise description of the problem
Motivation
I use typespec (compiler version
0.54.0
) to describe my API and generate openapi3 specification (@typespec/openapi3
emitter of version0.54.0
). This specification is shared across different commands to generate client for my service. One of the clients is written in c# and uses NSwag generator.The problem is that generated openapi spec does not contain explicitly defined attribute
additionalProperties: false
. It leads to generatingIDictionary<string, object> AdditionalProperties
for each generated type. Related issue in nswag.Seems like that the reason is json schema validation specification
Example
Model in typespec:
Generated OpenApi:
Generated c# code:
Proposal
It will be very useful to have opportunity to specify emitter option - specify explicitly additional properties or not. Like that:
or:
It should produce the following openapi:
Checklist