Skip to content

Commit 9c99e71

Browse files
committed
feat(openapi): Support OpenAPI 3.2. Deprecate Swagger 2.0
1 parent 5b89670 commit 9c99e71

10 files changed

Lines changed: 1112 additions & 51 deletions

File tree

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44

55
[Keyword Documentation](https://asyrjasalo.github.io/RESTinstance)
66

7+
Note: Since 1.7.0, Swagger (OpenAPI 2.0) support is deprecated,
8+
and will likely be removed in the future.
9+
710
## Advantages
811

912
1. **RESTinstance relies on Robot Framework's language-agnostic, clean
1013
and minimal syntax, for API tests.** It is neither tied to any
1114
particular programming language nor development framework. Using
1215
RESTinstance requires little, if any, programming knowledge. It
1316
builts on long-term technologies with well established communities,
14-
such as HTTP, JSON (Schema), Swagger/OpenAPI and Robot Framework.
17+
such as HTTP, JSON (Schema), OpenAPI and Robot Framework.
1518
2. **It validates JSON using JSON Schema, guiding you to write API
1619
tests to base on properties** rather than on specific values (e.g.
1720
"email must be valid" vs "email is foo@bar.com"). This approach
@@ -24,10 +27,9 @@
2427
and the schema gets more accurate by your tests.** Output the schema
2528
to a file and reuse it as expectations to test the other methods, as
2629
most of them respond similarly with only minor differences. Or
27-
extend the schema further to a full Swagger spec (version 2.0 and
28-
OpenAPI 3.0), which RESTinstance can test requests and
29-
responses against. All this leads to reusability, getting great test
30-
coverage with minimum number of keystrokes and very clean tests.
30+
extend the schema further to a full OpenAPI spec, which RESTinstance can
31+
test requests and responses against. All this leads to reusability, getting
32+
great test coverage with minimum number of keystrokes and very clean tests.
3133

3234
## Installation
3335

@@ -58,7 +60,7 @@ Documentation Test data can be read from variables and files.
5860
... Using (enum) values in tests optional. Only type is required.
5961
... All the JSON Schema validation keywords are also supported.
6062
... Thus, there is no need to write any own validation logic.
61-
... Not a long path from schemas to full Swagger/OpenAPI specs.
63+
... Not a long path from schemas to full OpenAPI specs.
6264
... The persistence of the created instances is the test suite.
6365
... Use keyword `Rest instances` to output the created instances.
6466
@@ -163,17 +165,15 @@ Contributors:
163165

164166
We use following Python excellence under the hood:
165167

166-
- [Flex](https://github.com/pipermerriam/flex), by Piper Merriam, for
167-
Swagger 2.0 validation
168168
- [GenSON](https://github.com/wolverdude/GenSON), by Jon "wolverdude"
169169
Wolverton, for JSON Schema generator
170170
- [jsonpath-ng](https://github.com/h2non/jsonpath-ng), by Tomas
171171
Aparicio and Kenneth Knowles, for handling JSONPath queries
172172
- [jsonschema](https://github.com/Julian/jsonschema), by Julian
173173
Berman, for JSON Schema validator
174+
- [openapi-core](https://github.com/python-openapi/openapi-core), by Artur Maciag
175+
et al., for OpenAPI validation
174176
- [pygments](http://pygments.org), by Georg Brandl et al., for JSON
175177
syntax coloring
176178
- [requests](https://github.com/requests/requests), by Kenneth Reitz
177179
et al., for making HTTP requests
178-
- [openapi-core](https://github.com/python-openapi/openapi-core), by Artur Maciag
179-
et al., for OpenAPI 3 validation

atest/spec_31_json.robot

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
*** Settings ***
2+
Library REST localhost:8273/
3+
... spec=${CURDIR}/swagger/spec_31.json
4+
5+
*** Test Cases ***
6+
GET to existing
7+
GET /users/1 allow_redirects=${None}
8+
9+
GET to non-existing
10+
GET /users/404 allow_redirects=true
11+
12+
GET many
13+
GET /users allow_redirects=false
14+
15+
GET many with query "_limit"
16+
GET /users?_limit=10 allow_redirects=${False}
17+
18+
GET many with invalid query
19+
GET /users?_invalid=query timeout=2.0
20+
21+
POST with invalid params
22+
POST /users { "name": "Alexander James Murphy" }
23+
24+
POST with valid params
25+
POST /users { "id": 100, "name": "Alexander James Murphy" }
26+
27+
POST with missing params
28+
POST /users
29+
30+
PUT to non-existing
31+
PUT /users/2043
32+
33+
PUT with invalid params
34+
PUT /users/100 { "id": 1801 }
35+
36+
PUT with valid params
37+
PUT /users/100 { "address": { "city": "Delta City" } }
38+
39+
PUT with missing params
40+
PUT /users/100
41+
42+
PATCH to non-existing
43+
PATCH /users/2043
44+
45+
PATCH with invalid params
46+
PATCH /users/100 { "nickname": "murph" }
47+
48+
PATCH with valid params
49+
PATCH /users/100 { "username": "murph" }
50+
51+
PATCH with missing params
52+
PATCH /users/100
53+
54+
DELETE to non-existing
55+
DELETE /users/2043
56+
57+
DELETE to existing
58+
DELETE /users/100
59+
60+
DELETE to invalid, but with no validations
61+
DELETE /invalid validate=false
62+
63+
GET non-documented endpoint
64+
Run Keyword And Expect Error
65+
... Path not found for http://localhost:8273/nope
66+
... GET /nope

atest/spec_31_yaml.robot

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
*** Settings ***
2+
Library REST localhost:8273/
3+
... spec=${CURDIR}/swagger/spec_31.yaml
4+
5+
*** Test Cases ***
6+
GET to existing
7+
GET /users/1 allow_redirects=${None}
8+
9+
GET to non-existing
10+
GET /users/404 allow_redirects=true
11+
12+
GET many
13+
GET /users allow_redirects=false
14+
15+
GET many with query "_limit"
16+
GET /users?_limit=10 allow_redirects=${False}
17+
18+
GET many with invalid query
19+
GET /users?_invalid=query timeout=2.0
20+
21+
POST with invalid params
22+
POST /users { "name": "Alexander James Murphy" }
23+
24+
POST with valid params
25+
POST /users { "id": 100, "name": "Alexander James Murphy" }
26+
27+
POST with missing params
28+
POST /users
29+
30+
PUT to non-existing
31+
PUT /users/2043
32+
33+
PUT with invalid params
34+
PUT /users/100 { "id": 1801 }
35+
36+
PUT with valid params
37+
PUT /users/100 { "address": { "city": "Delta City" } }
38+
39+
PUT with missing params
40+
PUT /users/100
41+
42+
PATCH to non-existing
43+
PATCH /users/2043
44+
45+
PATCH with invalid params
46+
PATCH /users/100 { "nickname": "murph" }
47+
48+
PATCH with valid params
49+
PATCH /users/100 { "username": "murph" }
50+
51+
PATCH with missing params
52+
PATCH /users/100
53+
54+
DELETE to non-existing
55+
DELETE /users/2043
56+
57+
DELETE to existing
58+
DELETE /users/100
59+
60+
DELETE to invalid, but with no validations
61+
DELETE /invalid validate=false
62+
63+
GET non-documented endpoint
64+
Run Keyword And Expect Error
65+
... Path not found for http://localhost:8273/nope
66+
... GET /nope

atest/spec_32_yaml.robot

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
*** Settings ***
2+
Library REST localhost:8273/
3+
... spec=${CURDIR}/swagger/spec_32.yaml
4+
5+
*** Test Cases ***
6+
GET to existing
7+
GET /users/1 allow_redirects=${None}
8+
9+
GET to non-existing
10+
GET /users/404 allow_redirects=true
11+
12+
GET many
13+
GET /users allow_redirects=false
14+
15+
GET many with query "_limit"
16+
GET /users?_limit=10 allow_redirects=${False}
17+
18+
GET many with invalid query
19+
GET /users?_invalid=query timeout=2.0
20+
21+
POST with invalid params
22+
POST /users { "name": "Alexander James Murphy" }
23+
24+
POST with valid params
25+
POST /users { "id": 100, "name": "Alexander James Murphy" }
26+
27+
POST with missing params
28+
POST /users
29+
30+
PUT to non-existing
31+
PUT /users/2043
32+
33+
PUT with invalid params
34+
PUT /users/100 { "id": 1801 }
35+
36+
PUT with valid params
37+
PUT /users/100 { "address": { "city": "Delta City" } }
38+
39+
PUT with missing params
40+
PUT /users/100
41+
42+
PATCH to non-existing
43+
PATCH /users/2043
44+
45+
PATCH with invalid params
46+
PATCH /users/100 { "nickname": "murph" }
47+
48+
PATCH with valid params
49+
PATCH /users/100 { "username": "murph" }
50+
51+
PATCH with missing params
52+
PATCH /users/100
53+
54+
DELETE to non-existing
55+
DELETE /users/2043
56+
57+
DELETE to existing
58+
DELETE /users/100
59+
60+
DELETE to invalid, but with no validations
61+
DELETE /invalid validate=false
62+
63+
GET non-documented endpoint
64+
Run Keyword And Expect Error
65+
... Path not found for http://localhost:8273/nope
66+
... GET /nope

0 commit comments

Comments
 (0)