Yes, the 3.0.0 spec was changed to allow that. I’m not sure if we support it 
yet in swagger-core 2.0. Mind filing a ticket?

 

 

 

From: <[email protected]> on behalf of Yuting 
<[email protected]>
Reply-To: "[email protected]" 
<[email protected]>
Date: Thursday, September 28, 2017 at 18:33
To: Swagger <[email protected]>
Subject: Re: How do I use swagger api to generate swagger with 
additionalProperties as false for object

 

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 Objectand 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]> 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].
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