Fair enough.

But perhaps the ship has sailed? A number of Swagger tools I have used 
allow booleans in additional properties and validate them correctly. For 
example the official json schema for Swagger 2 allows booleans in 
additional properties:
https://github.com/OAI/OpenAPI-Specification/blame/master/schemas/v2.0/schema.json#L1004

On Friday, 29 September 2017 12:22:00 UTC+10, Ron wrote:
>
> Ben,
>
>  
>
> I realize this is might sound a bit arrogant, but that’s not the intent. 
>
> Being the person who wrote the Swagger 2 specification, and spent hours 
> specifically on the Schema Object itself, I can assure you that the intent 
> was as I stated before. This is a mistake in the wording of the spec which 
> was never clarified properly – and it’s also the reason why the wording in 
> the 3.0.0 spec around additionalProperties is much more explicit.
>
>  
>
>  
>
>  
>
> *From: *<[email protected] <javascript:>> on behalf of Ben 
> Sayers <[email protected] <javascript:>>
> *Reply-To: *"[email protected] <javascript:>" <
> [email protected] <javascript:>>
> *Date: *Thursday, September 28, 2017 at 18:46
> *To: *Swagger <[email protected] <javascript:>>
> *Subject: *Re: How do I use swagger api to generate swagger with 
> additionalProperties as false for object
>
>  
>
> I believe the Swagger 2 specification does indeed allow additional 
> properties and that the default value is an empty schema. Here is my 
> reasoning:
>
>  
>
> This is the Swagger 2 definition for additional properties.
>
>  
>
> The following properties are taken from the JSON Schema definition but 
> their definitions were adjusted to the Swagger Specification. Their 
> definition is the same as the one from JSON Schema, only where the original 
> definition references the JSON Schema definition, the Schema Object 
> definition is used instead.
> items
> allOf
> properties
> additionalProperties
>
>  
>
> And this is the JSON Schema draft 4 specification's definition of 
> additional properties
>
>  
>
> 5.4.4.  additionalProperties, properties and patternProperties
> 5.4.4.1.  Valid values
>    The value of "additionalProperties" MUST be a boolean or an object.
>    If it is an object, it MUST also be a valid JSON Schema.
>
>  
>
> Swagger 2 uses the same definition from the JSON Schema specification 
> unless the value is a JSON Schema. Since the value false is a Boolean we 
> take the definition from the JSON Schema specification which says it is 
> allowed.
>
>  
>
> In regards to the default value again we take the definition from the JSON 
> Schema draft 4 specification:
>
>  
>
> 5.4.4.3.  Default values
>    If either "properties" or "patternProperties" are absent, they can be
>    considered present with an empty object as a value.
>    If "additionalProperties" is absent, it may be considered present
>    with an empty schema as a value.
>
>  
>
> Sources:
>
> Swagger 2 specification:  
> https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md
>
> JSON Schema draft 4 specification: 
> http://json-schema.org/specification-links.html#draft-4
>
>
> On Friday, 29 September 2017 06:22:35 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]> on behalf of Yuting <
> [email protected]>
> *Reply-To: *"[email protected]" <
> [email protected]>
> *Date: *Thursday, September 28, 2017 at 00:15
> *To: *Swagger <[email protected]>
> *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].
> 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] <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.

Reply via email to