-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Restrict Schema Object with additionalProperties: false #217
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
Comments
Not sure what you're referring to.
Schema Object is defined as the acceptable fields, which are in turn defined using the json schema's json schema on fields that use exactly the same definition - https://github.com/swagger-api/swagger-spec/blob/master/schemas/v2.0/schema.json#L879-L995 So what's missing? |
A Swagger like this gets validated: swagger: '2.0'
info:
version: "1.0.0"
title: petstore
paths:
/users:
get:
responses:
"200":
description: Describe the 200 response in more detail
definitions:
Pet:
properties:
name:
type: string
mohsen: 1 # shouldn't this be not allowed? |
JSON Schema by default is permissive. Which means, that by default, That actually makes the model definition you gave a valid one, especially if we validate against JSON Schema's json schema. However, we are more restrictive, and in that sense I did miss Was there anything else you encountered that you expected to not validate which validated? |
usually misspelling the |
That makes sense. I will change the title of the issue to better describe the problem. Feel free to add any other issues you've encountered (there are a few I'm aware of - the schema doesn't allow definition of 'additionalProperties' as part of the schema. Well, it does now, because it's not restricted, but I'll add that too). |
Models in
definitions
should be valid JSON schema. Although we don't support some of JSON Schema features, we can still use JSON Schema meta-schema to validate those.Right now definitions can have anything in it and it would be still valid
The text was updated successfully, but these errors were encountered: