Skip to content

ObjectProperty lacks additionalProperties #1349

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

Closed
2rs2ts opened this issue Aug 10, 2015 · 4 comments
Closed

ObjectProperty lacks additionalProperties #1349

2rs2ts opened this issue Aug 10, 2015 · 4 comments

Comments

@2rs2ts
Copy link

2rs2ts commented Aug 10, 2015

And yet, the petstore example has an operation with a response as an ObjectProperty with additionalProperties defined on it.

"/store/inventory": {
    "get": {
        "tags": ["store"],
        "summary": "Returns pet inventories by status",
        "description": "Returns a map of status codes to quantities",
        "operationId": "getInventory",
        "produces": ["application/json"],
        "parameters": [],
        "responses": {
            "200": {
                "description": "successful operation",
                "schema": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "integer",
                        "format": "int32"
                    }
                }
            }
        },
        "security": [{
            "api_key": []
        }]
    }
}

Shouldn't this be added to the ObjectProperty?

2rs2ts added a commit to 2rs2ts/swagger-gdd that referenced this issue Aug 10, 2015
@fehguy
Copy link
Contributor

fehguy commented Aug 11, 2015

I will add some tests around this, but as-is, it should deserialize this into a map with key type string and value java.lang.Integer

fehguy added a commit that referenced this issue Aug 11, 2015
fehguy added a commit that referenced this issue Aug 11, 2015
@fehguy
Copy link
Contributor

fehguy commented Aug 11, 2015

The deserializer handles addtional properties, see tests.

@fehguy fehguy closed this as completed Aug 11, 2015
@2rs2ts
Copy link
Author

2rs2ts commented Aug 12, 2015

Oh, so it deserializes to a MapProperty, not an ObjectProperty. Got it.

@ahl
Copy link

ahl commented Jan 20, 2017

sorry to dredge up this old thread, but @fehguy can I ask why this is the right behavior? It seems like it's legal to have swagger like this:

"schema": {
    "type": "object",
    "properties": { 
        "foo" {
            "type": "string"
        }
    },
    "additionalProperties": {
        "type": "integer",
        "format": "int32"
    }
}

If that is in fact legal, it would be useful to have additionalProperties on the ObjectProperty.

And forgive me if this is answered elsewhere, but what is the purpose of the MapProperty and/or how does it relate to the Swagger 2.0 spec? Thanks.

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

3 participants