Thanks Ron for the response! Is it possible in swagger api 2.0.0-rc1? I explored a bit but didn't find many clue. The 3.0 spec does explicitly say value can be boolean though.
- additionalProperties - Value can be boolean or object. Inline or referenced schema MUST be of a Schema Object <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject>and not a standard JSON Schema. On Friday, September 29, 2017 at 6:22:35 AM UTC+10, Ron wrote: > > The 2.0 specification doesn’t allow setting additionalProperties: false. > It was intended to be the default definition but was never clarified in the > spec. > > > > > > > > *From: *<[email protected] <javascript:>> on behalf of > Yuting <[email protected] <javascript:>> > *Reply-To: *"[email protected] <javascript:>" < > [email protected] <javascript:>> > *Date: *Thursday, September 28, 2017 at 00:15 > *To: *Swagger <[email protected] <javascript:>> > *Subject: *How do I use swagger api to generate swagger with > additionalProperties as false for object > > > > I somehow have to generate a swagger doc with addtionalProperties as false > to not allow additional properties. I looked at > https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-models/src/main/java/io/swagger/models/ModelImpl.java > > > but setAdditionalProperties accept a Property only, how do I set it with a > boolean value? > > public void setAdditionalProperties(Property additionalProperties) { > > > > type(OBJECT); > > > > this.additionalProperties = additionalProperties; > > } > > "TestDTO" : { > "type" : "object", > "additionalProperties":false > "properties" : { > "property1" : { > "description" : "This is a test object.", > "$ref" : "#/definitions/TestDTO" > }, > "perperty2" : { > "type" : "string", > "description" : "this is a property." > } > } > }, > > -- > You received this message because you are subscribed to the Google Groups > "Swagger" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > -- You received this message because you are subscribed to the Google Groups "Swagger" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
