Skip to content

Commit 0f5ac60

Browse files
authored
Merge pull request #178 from python-openapi/fix/references-docs-example-fix
References docs example fix
2 parents 56a4ebc + 2453001 commit 0f5ac60

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

docs/references.rst

+11-3
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ You can resolve JSON Schema references by passing registry
1717
],
1818
"properties": {
1919
"name": {
20-
"$ref": "#/components/schemas/Name"
20+
"$ref": "urn:name-schema"
2121
},
2222
"age": {
23-
"$ref": "#/components/schemas/Age"
23+
"$ref": "urn:age-schema"
2424
},
2525
"birth-date": {
26-
"$ref": "#/components/schemas/BirthDate"
26+
"$ref": "urn:birth-date-schema"
2727
}
2828
},
2929
"additionalProperties": False,
@@ -54,6 +54,14 @@ You can resolve JSON Schema references by passing registry
5454
],
5555
)
5656
57+
# If no exception is raised by validate(), the instance is valid.
5758
validate({"name": "John", "age": 23}, schema, registry=registry)
5859
60+
# raises error
61+
validate({"birth-date": "yesterday", "age": -1}, schema, registry=registry)
62+
63+
Traceback (most recent call last):
64+
...
65+
ValidationError: 'name' is a required property
66+
5967
For more information about resolving references see `JSON (Schema) Referencing <https://python-jsonschema.readthedocs.io/en/latest/referencing/>`__

0 commit comments

Comments
 (0)