Skip to content
This repository was archived by the owner on Nov 19, 2023. It is now read-only.

Commit ef24951

Browse files
authored
Unpin djangorestframework (#279)
* fix: Unpin `djangorestframework` The blocking drf-yasg issue has been resolved axnsan12/drf-yasg#810 * chore: Add package extras * chore: Bump version from 2.1.2 to 2.1.3 * chore: Update pre-commit hooks * docs: Update readme
1 parent 5029a33 commit ef24951

File tree

6 files changed

+144
-142
lines changed

6 files changed

+144
-142
lines changed

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
python -m venv .venv
6565
source .venv/bin/activate
6666
pip install wheel setuptools pip -U
67-
poetry install --no-interaction --no-root
67+
poetry install --no-interaction --no-root --extras drf-spectacular --extras drf-yasg
6868
if: steps.cache-venv.outputs.cache-hit != 'true'
6969
- run: |
7070
source .venv/bin/activate

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 22.8.0
3+
rev: 22.10.0
44
hooks:
55
- id: black
66

@@ -31,7 +31,7 @@ repos:
3131
]
3232

3333
- repo: https://github.com/asottile/pyupgrade
34-
rev: v2.38.1
34+
rev: v3.0.0
3535
hooks:
3636
- id: pyupgrade
3737
args: [ "--py3-plus", "--py36-plus", "--py37-plus" ]
@@ -42,7 +42,7 @@ repos:
4242
- id: isort
4343

4444
- repo: https://github.com/pre-commit/mirrors-mypy
45-
rev: v0.971
45+
rev: v0.982
4646
hooks:
4747
- id: mypy
4848
additional_dependencies:

README.md

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,32 @@ pip install drf-openapi-tester
2020

2121
## Usage
2222

23-
First instantiate one or more instances of SchemaTester:
23+
Instantiate one or more instances of `SchemaTester`:
2424

2525
```python
2626
from openapi_tester import SchemaTester
2727

2828
schema_tester = SchemaTester()
29-
30-
3129
```
3230

3331
If you are using either [drf-yasg](https://github.com/axnsan12/drf-yasg)
3432
or [drf-spectacular](https://github.com/tfranzel/drf-spectacular) this will be auto-detected, and the schema will be
35-
loaded by the SchemaTester automatically. If you are using schema files though, you will need to pass the file path to
36-
the tester:
33+
loaded by the `SchemaTester` automatically.
34+
35+
If you are using schema files, you will need to pass the file path:
3736

3837
```python
3938
from openapi_tester import SchemaTester
4039

4140
# path should be a string
4241
schema_tester = SchemaTester(schema_file_path="./schemas/publishedSpecs.yaml")
43-
44-
4542
```
4643

47-
Once you instantiate a tester, you can use it to test responses:
44+
Once you've instantiated a tester, you can use it to test responses:
4845

4946
```python
5047
from openapi_tester.schema_tester import SchemaTester
5148

52-
# you need to create at least one instance of SchemaTester.
53-
# you can pass kwargs to it
5449
schema_tester = SchemaTester()
5550

5651

@@ -60,7 +55,7 @@ def test_response_documentation(client):
6055
schema_tester.validate_response(response=response)
6156
```
6257

63-
If you are using the Django testing framework, you can create a base APITestCase that incorporates schema validation:
58+
If you are using the Django testing framework, you can create a base `APITestCase` that incorporates schema validation:
6459

6560
```python
6661
from rest_framework.response import Response
@@ -131,7 +126,7 @@ def my_test(client):
131126

132127
### case_tester
133128

134-
The case tester argument takes a callable that is used to validate the key casings of both schemas and responses. If
129+
The case tester argument takes a callable that is used to validate the key case of both schemas and responses. If
135130
nothing is passed, case validation is skipped.
136131

137132
The library currently has 4 built-in case testers:
@@ -141,11 +136,11 @@ The library currently has 4 built-in case testers:
141136
- `is_camel_case`
142137
- `is_kebab_case`
143138

144-
You can of course pass your own custom case tester.
139+
You can use one of these, or your own.
145140

146141
### ignore_case
147142

148-
List of keys to ignore when testing key casing. This setting only applies when case_tester is not `None`.
143+
List of keys to ignore when testing key case. This setting only applies when case_tester is not `None`.
149144

150145
### validators
151146

@@ -171,7 +166,7 @@ def my_uuid_4_validator(schema_section: dict, data: Any) -> Optional[str]:
171166

172167
### field_key_map
173168

174-
You can pass an optional dictionary that maps custom url parameter names into values, for cases where this cannot be
169+
You can pass an optional dictionary that maps custom url parameter names into values, for situations where this cannot be
175170
inferred by the DRF `EndpointEnumerator`. A concrete use case for this option is when
176171
the [django i18n locale prefixes](https://docs.djangoproject.com/en/3.1/topics/i18n/translation/#language-prefix-in-url-patterns).
177172

@@ -185,10 +180,9 @@ schema_tester = SchemaTester(field_key_map={
185180

186181
## Schema Validation
187182

188-
When the SchemaTester loads a schema, it runs it through
189-
[OpenAPI Spec validator](https://github.com/p1c2u/openapi-spec-validator) which validates that the schema passes without
190-
specification compliance issues. In case of issues with the schema itself, the validator will raise the appropriate
191-
error.
183+
When the SchemaTester loads a schema, it parses it using an
184+
[OpenAPI spec validator](https://github.com/p1c2u/openapi-spec-validator). This validates the schema.
185+
In case of issues with the schema itself, the validator will raise the appropriate error.
192186

193187
## Django testing client
194188

0 commit comments

Comments
 (0)