Add support for patternProperties in schemas
See original GitHub issueJSON Schema draft 4 has patternProperties
which is not supported by Swagger 2.0.
patternProperties allows to have loosely defined objects where the list of keys is not fixed in the spec (like additionalProperties
allows in Swagger 2.0), but the format of the keys is restricted with a regexp (contrary to additionalProperties
where keys are not at all limited).
Here is a use case from #380:
name: pop
description: population by country
type: object
patternProperties:
'^[A-Z]{2}$':
type: integer
description: the population of the country indicated by the property name.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:48
- Comments:22 (14 by maintainers)
Top Results From Across the Web
How to use patternProperties in the Json Schema
additionalProperties only works by evaluating properties and patternProperties within the same schema object. "sensor_aaa" is consider valid ...
Read more >object — Understanding JSON Schema 2020-12 documentation
The additionalProperties keyword is used to control the handling of extra stuff, that is, properties whose names are not listed in the properties...
Read more >Support for patternProperties? - JSON Forms community
What I want is some kind ability to add/delete a new field/property. I am imagining something similar to what I see with arrays...
Read more >JSON Schema - Advanced Example
This example shows a possible JSON representation of a hypothetical machine's mount points as represented in an /etc/fstab file.
Read more >Additional Properties - Liquid Technologies
Second step: schemas in "patternProperties"; 8.3.3.4. ... The schema defined by "additionalProperties" is added to "s" if and only if, at this stage, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No,
patternProperties
did not make it into 3.0.So, how can we help get patternProperties into the OAS spec? The lack of this is really hampering our ability to express our response objects in OAS.
Use case:
We have an API that allows a customer to ask “what do you know about these things?”, where things can be of different types. We use the values passed in as the keys in the response to say “here’s what we know about this item”.