Comments (3)
The model template only generates the decoder.DisallowUnknownFields()
code if the generator thinks that additional properties are not allowed: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/go/model_simple.mustache#L493-L511
What config are you passing in when running the generator? There is a disallowAdditionalPropertiesIfNotPresent
config option that controls the behavior of generated code for all languages: https://openapi-generator.tech/docs/generators/go/#config-options
For legacy reasons, the disallowAdditionalPropertiesIfNotPresent
defaults to true
. This means that by default, the generator will produce models that assume additional properties are not allowed if the additionalProperties
key is not explicitly specified.
To configure the generator to produce code that complies with the additionalProperties
behavior documented in OAS, you have to set disallowAdditionalPropertiesIfNotPresent
to false
.
from openapi-generator.
@wing328 @ctreatma
Please, check this bug.
from openapi-generator.
@ctreatma
Thank you! I did not know about disallowAdditionalPropertiesIfNotPresent
config.
When I run the generator like docker run --rm -u 1001:1001 -v "${PWD}:/local" openapitools/openapi-generator-cli generate --additional-properties=disallowAdditionalPropertiesIfNotPresent=false -i /local/test.yaml -g go -o /local/out/go
, decoder.DisallowUnknownFields()
is not generated
from openapi-generator.
Related Issues (20)
- [BUG][JAVA] Regression in v7.6.0 creating incorrect `generateName=spring` code HOT 3
- [BUG][Java][native] Regression: DateTime in deepObjects is no longer serialized correctly
- [BUG][typescript-fetch] 7.6.0 regression: TS7053 errors in generated instanceOf* methods HOT 3
- [BUG][Go] enumUnknownDefaultCase does not return default case on JSON unmarshal
- [REQ] generators for terraform provider and CLI
- [BUG][Kotlin] NoSuchMethodError 'void com.fasterxml.jackson.core.base.GeneratorBase.<init>(int, com.fasterxml.jackson.core.ObjectCodec, com.fasterxml.jackson.core.io.IOContext)'
- [BUG] [C#] Optional parameters prevent deserialization HOT 4
- [REQ] [Java] Container bean validation customisation HOT 3
- C# Generator for WPF views
- [BUG][JAVA][NATIVE] useEnumCaseInsensitive option not working for Enum Classes (Works for inner classes)
- [REQ] Feature Request: Shared type between GET and POST methods instead of eg. GetFoo*Response and CreateFoo*Response HOT 1
- [REQ] Enable accessing child type `Bar` or `Baz` from the type `GetFoo*Response` / `CreateFoo*Response`
- [BUG] typescript-axios : Multiform POST enums being sent as Blob instead of string HOT 1
- [BUG][PHP] 204 response causes exception when path also has 200 response
- [BUG][PYTHON] Deserialize on basic str fails since new version HOT 1
- Compatibility issue with OWASP
- [BUG] [Java] BaseApi not found HOT 1
- [BUG] [kotlin] Wrong implicit Accept header sent when making requests to endpoint that expects HTTP 204
- [BUG] allOf doesn't create a new class but a method
- [BUG][PYTHON] Decoding accents problem using json.dumps() when using ascii characters
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-generator.