Commit graph

255 commits

Author SHA1 Message Date
p1c2u
fc60083e78 Get rid of schema validation in unmarshal 2019-09-13 01:55:22 +01:00
p1c2u
a2fc5284c6 Get rid of object validator 2019-09-12 19:56:39 +01:00
p1c2u
b2410e2f3a OAS 3.0 validator 2019-09-12 19:46:11 +01:00
p1c2u
c4c51637d2 Rename schema validate to obj_validate 2019-09-12 19:46:11 +01:00
p1c2u
f414b182c8 Version 0.11.1 2019-09-07 13:03:58 +01:00
p1c2u
5273a7ff7c Separate cast and unmarshal 2019-09-02 23:48:13 +01:00
Gerhard Weis
d490d5774b fix path parameter validation when overridden on operation 2019-06-20 06:23:54 +10:00
p1c2u
4ac4baf710 Version 0.11.0 2019-06-18 22:42:44 +01:00
Artur Maciag
27ebae3182 Parameters on path item object support 2019-06-18 16:31:42 +01:00
Artur Maciag
c9b2d8c4f8 attr errors hashable fix 2019-06-18 14:54:02 +01:00
Artur Maciag
9d9629b4bd Primitive types unmarshallers 2019-06-17 16:24:46 +01:00
A
9376b2e2da
Merge pull request #141 from bjmc/flask_params
Modify FlaskOpenAPIRequest to accomodate path variables
2019-06-17 15:38:45 +01:00
A
0df1d051b4
Merge pull request #133 from crunchr/support-any-type-with-one-of-rb1
Add support for one-of with any type
2019-06-17 13:28:41 +01:00
Brendan McCollam
3ef0c6adcf Convert Flask path variables to OpenAPI path parameters 2019-06-12 12:16:55 +01:00
Daniel Bradburn
d742a03f0f remove unused import 2019-06-08 11:03:58 +02:00
Artur Maciag
75840e0a95 Version 0.10.0 2019-05-21 13:21:42 +01:00
A
98f72bff1b
Merge pull request #134 from dz0ny/fix/number_parsing
Fix number validator
2019-05-21 13:19:07 +01:00
Artur Maciag
63f3ffb09f Number format added 2019-05-21 12:54:13 +01:00
A
f0cfa2d0e0
Merge pull request #131 from MCapitani/links
add support for "links" in Response
2019-05-21 12:26:32 +01:00
A
f5d26112b2
Merge pull request #130 from MCapitani/add-path-param
add support for path-level parameters
2019-05-17 10:30:51 +01:00
Janez Troha
3339e1311a Fix number validator
The `integer_types` is always a tuple. When checking
if an instance is a number it fails because it's doing a comparison against a tuple
instead of real type.

➜ python -c "from six import integer_types;import sys;print(integer_types);print(sys.version)"
(<type 'int'>, <type 'long'>)
2.7.16 (default, Apr  6 2019, 01:42:57)
[GCC 8.3.0]

➜ python3 -c "from six import integer_types;import sys;print(integer_types);print(sys.version)"
(<class 'int'>,)
3.7.3 (default, Apr  3 2019, 05:39:12)
[GCC 8.3.0]

And spec defines a number as both int and float https://swagger.io/docs/specification/data-models/data-types/#numbers so both validators need to support both types.
2019-05-15 19:00:38 +02:00
Daniel Bradburn
7d903a8907 Add support for one-of with any type 2019-05-02 15:50:38 +02:00
Nejc Zupan
13e65a2d91 Add missing STRING_FORMAT_CALLABLE_GETTER: SchemaFormat.PASSWORD
`password` is a valid OpenAPIv3 string format, that is used as a UI hint
for frontend clients to mask the input field.

It was already present in the `SchemaFormat` enum, but it was not
handled in `_unmarshal_string` that uses `STRING_FORMAT_CALLABLE_GETTER`
to decide how to unmarshal a string, which would result in an error like
this one:

```
Traceback (most recent call last):
  [... snip ...]
  File ".venv/lib/python3.7/site-packages/openapi_core/validation/request/validators.py", line 37, in validate
    body, body_errors = self._get_body(request, operation)
  File ".venv/lib/python3.7/site-packages/openapi_core/validation/request/validators.py", line 82, in _get_body
    body = media_type.unmarshal(raw_body, self.custom_formatters)
  File ".venv/lib/python3.7/site-packages/openapi_core/schema/media_types/models.py", line 45, in unmarshal
    unmarshalled = self.schema.unmarshal(deserialized, custom_formatters=custom_formatters)
  File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 189, in unmarshal
    casted = self.cast(value, custom_formatters=custom_formatters, strict=strict)
  File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 179, in cast
    return cast_callable(value)
  File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 295, in _unmarshal_object
    value, custom_formatters=custom_formatters)
  File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 335, in _unmarshal_properties
    prop_value, custom_formatters=custom_formatters)
  File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 189, in unmarshal
    casted = self.cast(value, custom_formatters=custom_formatters, strict=strict)
  File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 179, in cast
    return cast_callable(value)
  File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 295, in _unmarshal_object
    value, custom_formatters=custom_formatters)
  File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 335, in _unmarshal_properties
    prop_value, custom_formatters=custom_formatters)
  File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 189, in unmarshal
    casted = self.cast(value, custom_formatters=custom_formatters, strict=strict)
  File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 179, in cast
    return cast_callable(value)
  File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 215, in _unmarshal_string
    formatstring = self.STRING_FORMAT_CALLABLE_GETTER[schema_format]
KeyError: <SchemaFormat.PASSWORD: 'password'>
```
2019-04-26 20:22:54 +01:00
Artur Maciag
4d99cbe7e1 Move additional props check to separate method 2019-03-26 13:27:44 +00:00
Diogo Baeder de Paula Pinto
b029066add Fix #124: Checking "additionalProperties" in "oneOf" items.
This is important because it does the correct validation over items that
are restricted in "oneOf", so that it's possible to use schemas that are
superset of one another as items of "oneOf".
2019-03-26 02:30:07 -03:00
Artur Maciag
5f7c6ba6ee Version 0.9.0 2019-03-22 14:55:06 +00:00
Artur Maciąg
f8e4e34e39 String byte format fix 2019-03-22 14:35:12 +00:00
A
beaa08a9c0
Merge branch 'master' into master 2019-03-22 13:29:04 +00:00
A
aa978cbe00
Merge pull request #121 from ondratu/master
Object additionalProperties support
2019-03-22 13:21:43 +00:00
Artur Maciąg
cd0ca5d26f Raw value type strict validation 2019-03-22 11:21:50 +00:00
Ondrej Tuma
cfaeb03120 no version change 2019-03-13 19:55:39 +01:00
Ondrej Tuma
83b9c37915 Object additionalProperties support
* Default is true like in specification
* When is set false, it works like in past
* Object with types works
2019-03-12 16:01:28 +01:00
Marco Capitani
f748783842 add support for "links" in Response 2019-03-08 14:12:11 +01:00
Marco Capitani
f232f7419b add support for path-level parameters 2019-03-08 10:19:09 +01:00
Diogo Baeder de Paula Pinto
a08b62035e Properly formatting UUID if value to be unmarshalled is already a UUID.
Before this change, if a UUID instance got received as value in the
Schema, it was breaking the unmarshal because UUID instances can't be
used as values to instantiate other UUIDs.
2019-02-28 18:25:22 -03:00
Artur Maciag
395f68b234 Version 0.8.0 2019-02-28 14:20:06 +00:00
Artur Maciag
a533a080cc byte string format 2019-02-27 00:59:45 +00:00
Diogo Baeder de Paula Pinto
dadf075670 Accepting uuid string format and validating accordingly. 2019-02-26 02:57:50 -03:00
A
d07a9d0e63
Merge pull request #106 from benhowes/patch-1
Dont use value for determining any type
2019-02-24 02:11:11 +00:00
Berend Kapelle
f08257b853
fix test for non utc systems.
`strict_rfc3339.rfc3339_to_timestamp()` is tz aware
`datetime.datetime.fromtimestamp` is not

this causes  the test `test_string_format_datetime` to fail on
system that are not on utc
2019-01-28 14:43:24 +01:00
Ben Howes
3d2926871b
Dont use value for determining any type
otherwise Falsy values are not valid types
2018-12-11 14:49:13 +00:00
Artur Maciag
db5d825395 Version 0.7.1 2018-10-29 10:19:49 +00:00
Artur Maciag
4db726bdd7 Version 0.7.0 2018-10-25 13:05:59 +01:00
A
114ab79162
Merge branch 'master' into date-time-rfc3339 2018-09-13 20:42:32 +01:00
Domen Kožar
e1c64792d2
typo 2018-09-13 13:57:59 +01:00
Domen Kožar
399602f013
sync master changes with exception refactoring 2018-09-13 11:59:44 +01:00
Domen Kožar
17ea740b7b
Add field name to all property errors 2018-09-13 10:58:36 +01:00
Domen Kožar
b66ec04ac2
parameters/body should catch all schema errors 2018-09-13 10:58:35 +01:00
Domen Kožar
6bdd1a6756
Rewrok exception handling
Main motivation behind this change is to be able to catch exceptions
as per raise_for_errors() helpers, but to inspect state of exceptions
instead of just getting a rendered string. This allows rendering
exceptions into JSON, for example.
2018-09-13 10:58:35 +01:00
Domen Kožar
89a53f6edc
review feedback 2018-09-13 10:58:33 +01:00
Domen Kožar
64628d1cc9
Sketch out custom formatters design 2018-09-13 10:41:34 +01:00
Domen Kožar
286e26c4ed
openapi 3.0 defines date-time format to be rfc3339 2018-09-12 15:16:46 +01:00
8db5c08ed1 Add support for additional validation properties
Add support for the following validation properties:
- multipleOf
- maximum
- exclusiveMaximum
- minimum
- exclusiveMinimum
- maxLength
- minLength
- pattern
- maxItems
- minItems
- uniqueItems
- maxProperties
- minProperties

Fixes #49
2018-09-09 00:30:38 -04:00
Marcin Molenda
e5cb549ea1 Expose tags in Operation object 2018-08-31 16:57:53 +02:00
p1c2u
82a24f7ec4 Version 0.6.0 2018-08-23 21:42:53 +01:00
p1c2u
0cbbdb0232 Unmarshal any schema type 2018-08-23 09:29:36 +01:00
p1c2u
05b8a30091 Any schema type 2018-08-22 14:27:32 +01:00
Artur Maciag
82f32be1e7 String validation 2018-08-22 13:49:24 +01:00
Artur Maciag
e395b50558 Collection validation 2018-08-22 10:29:39 +01:00
Artur Maciag
3aaa3ceb8b Separate type and structure validation 2018-08-22 10:05:15 +01:00
p1c2u
0915e94530 Object validation 2018-08-22 09:34:18 +01:00
Artur Maciag
f9a7472c92 Separate schema casting and validation 2018-08-17 18:35:21 +01:00
Artur Maciag
7aaa5170a6 Parameter get_value restructure 2018-08-17 14:29:41 +01:00
Artur Maciag
b75798aa62 Handle parameter deserialization errors 2018-08-17 13:25:31 +01:00
grktsh
d4f65a2ed2 Support unmarshaling string with format keyword 2018-08-17 13:25:12 +09:00
A
ac797bcf2a
Merge pull request #46 from HoverHell/paramlocations
Request headers and cookies parameter parsing fix
2018-08-13 20:21:46 +01:00
Sean Marlow
23af33b7ca
Replace unicode character for RPM build.
To make building RPMs of package easier when using ascii by
default.
2018-07-31 11:52:52 -06:00
p1c2u
a9d858e940 Python2 compatibility module 2018-07-29 00:16:30 +01:00
p1c2u
f95608493a Merge branch 'master' of git://github.com/kcem/openapi-core into kcem-master 2018-07-28 23:15:20 +01:00
p1c2u
3ab55e44bd Lazy schema references 2018-07-28 22:12:47 +01:00
Rafael Caricio
15fc9b009a Makes it possible to access API examples 2018-07-24 09:47:02 +02:00
Rafael Caricio
8ab0b6206e Populate operation_id attr 2018-07-23 18:02:51 +02:00
Konrad Cempura
e3dfee56cd Python 2.7: Requirements for older python and patches for imports 2018-07-15 23:46:43 +02:00
Konrad Cempura
b8c03d90f4 Python 2.7: Copy list using slice 2018-07-15 23:46:38 +02:00
Konrad Cempura
88efa69cfd Python 2.7: Check instance on string_types from six instead of str 2018-07-15 23:46:34 +02:00
Konrad Cempura
1b9bb11114 Python 2.7: Remove Yarl from requirements 2018-07-15 23:46:30 +02:00
Konrad Cempura
64ac723e54 Python 2.7: Declare UTF-8 in files with non-ascii characters 2018-07-15 23:46:26 +02:00
Artur Maciag
f8e977cc17 Parameters tests 2018-07-09 12:10:05 +01:00
HoverHell
742268fe09 Request headers and cookies parameter parsing fix 2018-06-12 19:44:30 +03:00
Artur Maciag
8f22b6a30a Version 0.5.0 2018-05-30 15:13:34 +01:00
Artur Maciag
54b8011603 Mimetype wildcards support 2018-05-30 15:01:01 +01:00
Artur Maciag
78f55ee80f Schema additional properties support 2018-05-30 11:20:35 +01:00
Artur Maciag
d87b60ade7 Schema format accepts any value 2018-05-30 09:41:34 +01:00
Artur Maciag
4c75f0f9b7 OneOf schema support 2018-05-25 16:50:09 +01:00
Artur Maciag
36f7d4edf4 PEP8 fixes 2018-05-25 11:30:50 +01:00
Artur Maciag
4e1a61aace Exceptions restructure 2018-05-25 11:30:50 +01:00
Artur Maciag
9b05d7b271 Wrapper restructure 2018-05-25 11:30:50 +01:00
Artur Maciag
7111a91cef Validators restructure 2018-05-25 11:30:50 +01:00
Artur Maciag
734a4673f8 Schema objects restructure 2018-05-25 11:30:50 +01:00
Artur Maciag
353db1f4f8 validate_data shortcut import fix 2018-04-24 12:51:38 +01:00
Artur Maciag
7214eac33d Version 0.4.3 2018-04-24 12:44:26 +01:00
p1c2u
0350562b54 Response JSON text as array fix 2018-04-23 20:40:54 +01:00
amcmanigal
84d36e33c5 Revert "Updating Version"
This reverts commit c18c4a53f2.
2018-04-09 10:30:41 -04:00
amcmanigal
c18c4a53f2 Updating Version 2018-04-05 10:57:08 -04:00
amcmanigal
56be4b10eb Fixing Subschema Required Properties Validation
Currently if valid swagger syntax is used for model composition an
error will be thrown due to the lack of a type property. This was
corrected by making object the default type.

schema_type = schema_deref.get('type', 'object')

I changed the swagger definition to test for this. Now PetCreate is a
composite of PetCreatePartOne and PetCreatePartTwo. However, this
caused `test_post_pets_empty_body` to fail, which turned out to be a
bug in the required properties.

In `_unmarshal_object` the `get_all_properties` method is called to get
all properties from the subschemas. However, this is not done for
required properties, meaning that only top level required properties
will be correctly validated. I have added a
`get_all_required_properties’ to fix this.

This caused `test_get_pets` to fail. In this case the bug allowed an
incorrect test case to be introduced. Pet requires `id`, but it also
requires name because it inherits from PetCreate. I have fixed this
test case by adding the missing required property.

After these changes `test_get_pet_not_found` failed due to a string
formatting error (double quotes vs single quotes). I fixed this by
switching to dictionary comparisons.
2018-04-04 10:15:45 -04:00
Artur Maciag
8d92c25c11 Version 0.4.2 2018-04-04 11:52:41 +01:00
Artur Maciag
c733f9434a Allow undefined schema type 2018-04-04 11:26:21 +01:00
Artur Maciag
4a9cd2b1cb Werkzeug as extra requirement fix 2018-03-05 15:57:12 +00:00
Artur Maciag
e186e17556 Version 0.4.1 2018-02-28 15:11:43 +00:00
A
a3853da056
Merge pull request #15 from pbasista/bugfix/empty-servers
Add the default value for the 'servers' array
2018-02-28 15:09:05 +00:00
A
3cc1101288
Merge pull request #13 from pbasista/bugfix/default-values
Use appropriate default values for OpenAPI object fields
2018-02-28 15:02:59 +00:00
A
c30bef179d
Merge pull request #16 from p1c2u/fix/boolean-value-cast-fix
Boolean value cast fix
2018-02-28 13:47:43 +00:00
Artur Maciag
b1f58d7261 Boolean value cast fix 2018-02-28 13:39:23 +00:00
Peter Bašista
a0305fb97d Add the default value for the 'servers' array
The specification:

https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#oasObject

requires that if the 'servers' array is not provided or empty,
its default value is an array of a single Server Object
with 'url' of '/'.
2018-02-18 09:38:00 +01:00
Peter Bašista
821f14e84b Consistently yield tuples of variable_name and variable 2018-02-15 17:33:25 +01:00
Peter Bašista
48dba2c576 Use a more generic test for path item object's operations
Get the list of allowed operations from openapi_spec_validator:
b2e439aa79/openapi_spec_validator/validators.py (L157)
2018-02-09 19:55:25 +01:00
Peter Bašista
42923990ed Use a more generic test for path item object's operations
Get the list of allowed operations from openapi_spec_validator:
b2e439aa79/openapi_spec_validator/validators.py (L157)
2018-02-09 19:48:52 +01:00
Peter Bašista
49c2330810 Use appropriate default values for OpenAPI object fields
The specification:

https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#schemaObject

clearly states that fields:

- #/info
- #/paths
- #/components
- #/components/schemas
- #/components/responses
- #/components/parameters
- #/components/requestBodies

are objects.
2018-02-09 17:41:39 +01:00
Artur Maciag
e451c9f10c Version 0.4.0 2017-11-14 16:21:32 +00:00
Artur Maciag
6254d800a8 Use location local variable fix 2017-11-14 16:15:50 +00:00
Artur Maciag
fd450e6be6 Parameter deserializers 2017-11-14 16:05:03 +00:00
Artur Maciag
2d50e920ab Schema enum 2017-11-14 13:36:05 +00:00
Artur Maciag
b777ac4bfe Parameter enums 2017-11-14 11:28:45 +00:00
Artur Maciag
56f6a6db7d Version 0.3.4 2017-11-06 17:31:02 +00:00
Artur Maciag
1739828559 AllOf support 2017-11-06 16:50:00 +00:00
Artur Maciag
cffa0b4528 Version 0.3.3 2017-11-06 15:08:48 +00:00
Artur Maciag
219d1c650e Flask wrapper status code fix 2017-11-06 15:08:21 +00:00
Artur Maciag
dcb53244f2 Version 0.3.2 2017-11-06 14:57:32 +00:00
Artur Maciag
b69e268701 Response dereference support 2017-11-06 14:57:08 +00:00
Artur Maciag
12dcc8cde4 Version 0.3.1 2017-11-06 14:41:41 +00:00
Artur Maciag
b9a8477cd5 Response validated_data shortcut 2017-11-06 14:32:46 +00:00
Artur Maciag
128971185a Response data renamed 2017-11-06 14:05:06 +00:00
Artur Maciag
3541793ff3 Check response invalid content type 2017-11-06 13:53:49 +00:00
Artur Maciag
08fdf7c9aa Response validator 2017-11-06 13:32:31 +00:00
Artur Maciag
b0c4141f64 Response ranges support 2017-11-06 11:19:18 +00:00
Artur Maciag
1a05e7da89 Responses and headers objects 2017-11-06 11:00:13 +00:00
Artur Maciag
3fe1e6e458 Version 0.3.0 2017-11-03 15:12:25 +00:00
Artur Maciag
ad27ac9840 Import error loop fix 2017-11-03 15:11:50 +00:00
Artur Maciag
ca988528e7 Wrapper class for shortcuts 2017-11-03 15:04:18 +00:00
Artur Maciag
78afae3104 raise_for_errors method renamed 2017-11-03 14:55:21 +00:00
Artur Maciag
6f1e45e255 Flask wrapper added 2017-11-03 14:17:38 +00:00
Artur Maciag
624bf3de95 Validate body and parameters shortcuts 2017-11-03 11:40:05 +00:00
Artur Maciag
37f09d7571 Factories and exceptions cleanup 2017-11-03 11:18:48 +00:00
Artur Maciag
9bdb13f654 Request validator 2017-11-02 16:05:25 +00:00
Artur Maciag
a61a2494cb version 0.2.2 2017-10-19 12:29:13 +01:00
Artur Maciag
372f74f16e Allow empty value with default 2017-10-19 12:28:28 +01:00
Artur Maciag
0bf001648a Invalid operation error 2017-10-19 10:34:20 +01:00
Artur Maciag
a86c49d1be Parameter with required and allow empty value support 2017-10-18 14:42:23 +01:00
Artur Maciag
279ace9ed0 version 0.2.0 2017-10-17 14:49:21 +01:00
Artur Maciag
2491454c2a Schema deprecated value 2017-10-17 14:33:46 +01:00
Artur Maciag
943ca126fc Schema deprecated value 2017-10-17 14:23:26 +01:00
Artur Maciag
1ca11c9d19 Schema nullable value 2017-10-17 14:02:21 +01:00
Artur Maciag
01e7a5b688 version 0.1.4 2017-10-09 16:04:59 +01:00
Artur Maciag
6e07b0a040 content_type renamed to mimetype 2017-10-09 15:57:07 +01:00
Artur Maciag
fc28729eea version 0.1.3 2017-09-25 15:20:39 +01:00
Artur Maciag
be7f55d967 schema strict validation 2017-09-25 15:15:00 +01:00
Artur Maciag
aaab71c94e version 0.1.2 2017-09-25 14:21:13 +01:00
Artur Maciag
1b63bf9199 request method case fix 2017-09-25 14:20:23 +01:00
Artur Maciag
2cc3e243b4 version 0.1.1 2017-09-25 12:35:51 +01:00
Artur Maciag
d60bde446d servers with request validation 2017-09-25 12:29:16 +01:00