Skip to content

Commit 7216c61

Browse files
committed
test(OAS3.1): add tests for InfoObject.summary field
Refs OAI/OpenAPI-Specification#2251
1 parent 4dd6066 commit 7216c61

File tree

4 files changed

+125
-0
lines changed

4 files changed

+125
-0
lines changed

test/oas3_1/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# OpenAPI 3.1 tests
2+
3+
This directory contains tests for changes that made it into [OpenAPI 3.1 specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md).
4+
Changes are categorized into 4 distinct groups:
5+
6+
- **Additions**
7+
- **Changes**
8+
- **Extended Functionality**
9+
- **Breaking Changes**
10+
11+
All changes are documented in OpenAPI 3.1 [changelog](https://github.com/OAI/OpenAPI-Specification/pull/2251).
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"title": "Testing API",
5+
"summary": "info object summary",
6+
"version": "1.0.0"
7+
},
8+
"components": {
9+
"schemas": {
10+
"user": {
11+
"properties": {
12+
"id": {
13+
"type": "integer"
14+
}
15+
}
16+
}
17+
}
18+
},
19+
"servers": [
20+
{
21+
"url": "http://localhost:8080"
22+
}
23+
],
24+
"paths": {
25+
"/users": {
26+
"get": {
27+
"operationId": "getUserList",
28+
"description": "Get list of users",
29+
"responses": {
30+
"200": {
31+
"description": "List of users",
32+
"content": {
33+
"application/json": {
34+
"schema": {
35+
"$ref": "#/components/schemas/user"
36+
}
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"title": "Testing API",
5+
"version": "1.0.0"
6+
},
7+
"components": {
8+
"schemas": {
9+
"user": {
10+
"properties": {
11+
"id": {
12+
"type": "integer"
13+
}
14+
}
15+
}
16+
}
17+
},
18+
"servers": [
19+
{
20+
"url": "http://localhost:8080"
21+
}
22+
],
23+
"paths": {
24+
"/users": {
25+
"get": {
26+
"operationId": "getUserList",
27+
"description": "Get list of users",
28+
"responses": {
29+
"200": {
30+
"description": "List of users",
31+
"content": {
32+
"application/json": {
33+
"schema": {
34+
"$ref": "#/components/schemas/user"
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import SwaggerClient from '../../../../src';
2+
3+
describe('OpenAPI Specification 3.1', () => {
4+
describe('InfoObject.summary', () => {
5+
describe('given definition without summary field', () => {
6+
const spec = require('./data/without-field.json');
7+
8+
test('should not contain summary field in resolved spec', async () => {
9+
const client = await new SwaggerClient({ spec });
10+
11+
expect(client.spec.info.summary).toBeUndefined();
12+
expect(client.originalSpec.info.summary).toBeUndefined();
13+
});
14+
});
15+
16+
describe('given definition with summary field', () => {
17+
const spec = require('./data/with-field.json');
18+
19+
test('should contain summary field in resolved spec', async () => {
20+
const client = await new SwaggerClient({ spec });
21+
22+
expect(client.spec.info.summary).toStrictEqual('info object summary');
23+
expect(client.originalSpec.info.summary).toStrictEqual('info object summary');
24+
});
25+
});
26+
});
27+
});

0 commit comments

Comments
 (0)