[Swagger 2.0] additionalProperties?

4,725 views
Skip to first unread message

mission liao

unread,
Nov 13, 2014, 6:17:56 AM11/13/14
to swagger-sw...@googlegroups.com
Hi,

   In there, additionalProperties is used to describe Map primitives. However, I can't locate this property in Schema object in spec.

   Is this a miss or intended?

Ron

unread,
Nov 13, 2014, 6:19:58 AM11/13/14
to swagger-sw...@googlegroups.com
It's in the spec document (look at the Schema Object) but not in the json-schema. It's on my todo list to add.

--
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 swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mission liao

unread,
Nov 13, 2014, 6:25:33 AM11/13/14
to swagger-sw...@googlegroups.com
Got it, I will assume it there.


On Thursday, 13 November 2014 19:19:58 UTC+8, Ron R wrote:
It's in the spec document (look at the Schema Object) but not in the json-schema. It's on my todo list to add.
On 13 November 2014 13:17, mission liao <mission...@gmail.com> wrote:
Hi,

   In there, additionalProperties is used to describe Map primitives. However, I can't locate this property in Schema object in spec.

   Is this a miss or intended?

--
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 swagger-swaggersocket+unsub...@googlegroups.com.

Sushil Singh

unread,
Dec 31, 2014, 5:42:08 AM12/31/14
to swagger-sw...@googlegroups.com
Would greatly appreciate it if you post and example of how to use additionalProperties for Map ?

Ron

unread,
Dec 31, 2014, 6:52:25 AM12/31/14
to swagger-sw...@googlegroups.com
The object definition of additionalProperties pretty much limits its type.

So, if you have this:

"additionalProparties": { "type": "string" }

you're basically saying that you allow properties (as in keys) that have a value of type "string".

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Sushil Singh

unread,
Dec 31, 2014, 2:12:37 PM12/31/14
to swagger-sw...@googlegroups.com
Thanks for the quick response Ron, Another question.
 
How is the datatype of the key specified ? is it always assumed to be string ?

In the example mentioned at "https://github.com/mission-liao/pyswagger/issues/18" there is a map called "add_prop" defined.
The example also specifies the following JSON to be valid for the schema 
{
    "name_of_map": "my map",
    "prop1": {
        "id": 1,
        "name": "property 1"
    },
    "prop2": {
        "id": 2,
        "name": "property no. 2"
    },
}
The keys in the map are "prop1" and "prop2". Is the key type by default going to be string ?
Also any idea when swagger UI will show correct rendering of these map definitions.



On Wednesday, December 31, 2014 3:52:25 AM UTC-8, Ron R wrote:
The object definition of additionalProperties pretty much limits its type.

So, if you have this:

"additionalProparties": { "type": "string" }

you're basically saying that you allow properties (as in keys) that have a value of type "string".
On 31 December 2014 at 12:42, Sushil Singh <sush...@plumgrid.com> wrote:
Would greatly appreciate it if you post and example of how to use additionalProperties for Map ?


On Thursday, November 13, 2014 3:25:33 AM UTC-8, mission liao wrote:
Got it, I will assume it there.

On Thursday, 13 November 2014 19:19:58 UTC+8, Ron R wrote:
It's in the spec document (look at the Schema Object) but not in the json-schema. It's on my todo list to add.
On 13 November 2014 13:17, mission liao <mission...@gmail.com> wrote:
Hi,

   In there, additionalProperties is used to describe Map primitives. However, I can't locate this property in Schema object in spec.

   Is this a miss or intended?

--
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 swagger-swaggersocket+unsubscri...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ron

unread,
Dec 31, 2014, 2:18:57 PM12/31/14
to swagger-sw...@googlegroups.com
Keys are always strings. even if you could theoretically define them as numerical values, they would still be represented as strings.

If you're asking whether there's a way to restrict the structure of the key, then the answer is no.
That would require support for the 'patternedProperties' property (from JSON Schema) which we do not support in Swagger 2.0.

I cannot tell you when the UI will support maps (https://github.com/swagger-api/swagger-ui/issues/558), but of course, contributions are always appreciated.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Sushil Singh

unread,
Jan 2, 2015, 3:21:40 AM1/2/15
to swagger-sw...@googlegroups.com
Thanks for the response, It makes sense.

New years greetings. 

-Sushil
Reply all
Reply to author
Forward
0 new messages