Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for additionalProperties #18

Closed
mjgolinski opened this issue Dec 4, 2014 · 9 comments
Closed

Support for additionalProperties #18

mjgolinski opened this issue Dec 4, 2014 · 9 comments

Comments

@mjgolinski
Copy link

According to OAI/OpenAPI-Specification#38 (comment) swagger 2.0 supports additionalProperties. However i searched the codebase for string 'additionalProperties' and didn't find anything, hence my doubts.

@mjgolinski mjgolinski changed the title Is additionalProperties supported? Support for additionalProperties Dec 4, 2014
@mjgolinski
Copy link
Author

I checked it myself - it isn't supported. For us it's a showstopper because we have lots of maps in our API

@mission-liao
Copy link
Member

Interesting, I didn't see that property shown in the spec of Swagger 2.0. Let's me check how it works.

@mission-liao
Copy link
Member

Just found I asked similar question in Google Groups....

I tend to provide a partial support on additionalProperties for your case.

The problem is, this property contains 2 different types of value: a boolean or a Schema object.
To support what you need, I just need to support additionalProperties with a Schema object, which is easier.

The boolean case would be resolved later but not now, is that OK?
You could check the progress in this branch https://github.com/mission-liao/pyswagger/tree/addp

@mission-liao
Copy link
Member

Here is the testing case I would use in this case, let me know if this is not what you expected.

{
   "swagger":"2.0",
   "host":"http://test.com",
   "basePath":"/v1",
   "paths":{

   },
   "definitions":{
      "Category":{
         "properties":{
            "id":{
               "type":"integer",
               "format":"int64"
            },
            "name":{
               "type":"string"
            }
         }
      },
      "add_prop":{
         "properties":{
            "name_of_map":{
               "type":"string"
            }
         },
         "additionalProperties":{
            "$ref":"#/definitions/Category"
         }
      }
   }
}

@mjgolinski
Copy link
Author

Just to confirm, following JSON should fit your schema:

{
    "name_of_map": "my map",
    "prop1": {
        "id": 1,
        "name": "property 1"
    },
    "prop2": {
        "id": 2,
        "name": "property no. 2"
    },
}

If so, it's exactly what I need.
BTW could I also define additionalProperties inline (as opposed to using $ref)?

@mission-liao
Copy link
Member

Sure, it will works when inlined.

@mission-liao
Copy link
Member

Just create a PR, will be merged once we finished your PR.

@mission-liao
Copy link
Member

Just merge to master, will give a new build once Json_Reference is done.

@mission-liao
Copy link
Member

Just update a new build on pypi, you could verify this issue with new build.

For adding support on type:'number' or 'integer' without format, I gonna provide some way for users to register their own primitive handlers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants