encode / apistar

The Web API toolkit. 🛠
https://docs.apistar.com
BSD 3-Clause "New" or "Revised" License
5.57k stars 411 forks source link

allow schema generation for validators.Any type (#552) #561

Closed freakabcd closed 5 years ago

freakabcd commented 6 years ago

Don't bail out when an Any type is encountered.

According to my reading of the spec, {} is the type that represents Any. See the Quickstart section on http://json-schema.org/ and https://cswr.github.io/JsonSchema/spec/multiple_types/

freakabcd commented 6 years ago

Reading the spec again (carefully this time), especially this part (emphasis mine):

The most basic schema is a blank JSON object, which constrains nothing, allows anything, and describes nothing:

{}

You can apply constraints on an instance by adding validation keywords to the schema. For example, the “type” keyword can be used to restrict an instance to an object, array, string, number, boolean, or null

The schema should simply be {} without any specification of type (which only allows the specified values of [ object, array, string, number, boolean, null ] I'll amend the commit and push it up.

freakabcd commented 6 years ago

Can we comment out the pygments_css import in server/handlers.py ? It is generating build failures due to flake8 unused import.

danigosa commented 6 years ago

@freakabcd merge upstream, it's already gone

freakabcd commented 6 years ago

no-change amend commit pushed to retrigger CI

tomchristie commented 5 years ago

Redundant since https://github.com/encode/typesystem/blob/master/typesystem/fields.py now deals with validation etc.

(And correctly uses true for Any.)