Skip to content
This repository was archived by the owner on Dec 10, 2021. It is now read-only.

Commit c7aa9d9

Browse files
committed
Update test project with recursive schema
1 parent 4945b42 commit c7aa9d9

File tree

6 files changed

+1652
-511
lines changed

6 files changed

+1652
-511
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"definitions": {
4+
"folder": {
5+
"type": "object",
6+
"title": "Folder Schema",
7+
"properties": {
8+
"id": {
9+
"type": "string",
10+
"example": "3ba1c69c-3c81-4d6d-b304-873d898b2e3c",
11+
"format": "uuid"
12+
},
13+
"folders": {
14+
"type": "array",
15+
"items": {
16+
"$ref": "#/definitions/folder"
17+
}
18+
}
19+
},
20+
"additionalProperties": false,
21+
"required": ["id", "name", "folders", "checklists"]
22+
}
23+
},
24+
"type": "object",
25+
"title": "Folders Response Schema",
26+
"properties": {
27+
"data": {
28+
"$ref": "#/definitions/folder"
29+
}
30+
}
31+
}

test/project/openapi.yml

Lines changed: 114 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,91 @@
1-
openapi: 3.0.0-RC1
1+
openapi: 3.0.0
22
components:
33
schemas:
4+
meta:
5+
description: >-
6+
Non-standard meta-information that can not be represented as an
7+
attribute or relationship.
8+
type: object
9+
additionalProperties: true
10+
links:
11+
description: >-
12+
A resource object **MAY** contain references to other resource objects
13+
("relationships"). Relationships may be to-one or to-many. Relationships
14+
can be specified by including a member in a resource's links object.
15+
type: object
16+
properties:
17+
self:
18+
description: >-
19+
A `self` member, whose value is a URL for the relationship itself (a
20+
"relationship URL"). This URL allows the client to directly
21+
manipulate the relationship. For example, it would allow a client to
22+
remove an `author` from an `article` without deleting the people
23+
resource itself.
24+
type: string
25+
format: uri
26+
related:
27+
$ref: '#/components/schemas/link'
28+
additionalProperties: true
29+
link:
30+
description: >-
31+
A link **MUST** be represented as either: a string containing the link's
32+
URL or a link object.
33+
oneOf:
34+
- description: A string containing the link's URL.
35+
type: string
36+
format: uri
37+
- type: object
38+
required:
39+
- href
40+
properties:
41+
href:
42+
description: A string containing the link's URL.
43+
type: string
44+
format: uri
45+
meta:
46+
$ref: '#/components/schemas/meta'
47+
error:
48+
type: object
49+
properties:
50+
id:
51+
description: A unique identifier for this particular occurrence of the problem.
52+
type: string
53+
links:
54+
$ref: '#/components/schemas/links'
55+
status:
56+
description: >-
57+
The HTTP status code applicable to this problem, expressed as a
58+
string value.
59+
type: string
60+
code:
61+
description: 'An application-specific error code, expressed as a string value.'
62+
type: string
63+
title:
64+
description: >-
65+
A short, human-readable summary of the problem. It **SHOULD NOT**
66+
change from occurrence to occurrence of the problem, except for
67+
purposes of localization.
68+
type: string
69+
detail:
70+
description: >-
71+
A human-readable explanation specific to this occurrence of the
72+
problem.
73+
type: string
74+
source:
75+
type: object
76+
properties:
77+
pointer:
78+
description: >-
79+
A JSON Pointer [RFC6901] to the associated entity in the request
80+
document [e.g. "/data" for a primary data object, or
81+
"/data/attributes/title" for a specific attribute].
82+
type: string
83+
parameter:
84+
description: A string indicating which query parameter caused the error.
85+
type: string
86+
meta:
87+
$ref: '#/components/schemas/meta'
88+
additionalProperties: false
489
ErrorResponse:
590
title: JSON API Schema
691
description: >-
@@ -13,142 +98,12 @@ components:
1398
errors:
1499
type: array
15100
items:
16-
type: object
17-
properties:
18-
id:
19-
description: >-
20-
A unique identifier for this particular occurrence of the
21-
problem.
22-
type: string
23-
links:
24-
description: >-
25-
A resource object **MAY** contain references to other resource
26-
objects ("relationships"). Relationships may be to-one or
27-
to-many. Relationships can be specified by including a member
28-
in a resource's links object.
29-
type: object
30-
properties:
31-
self:
32-
description: >-
33-
A `self` member, whose value is a URL for the relationship
34-
itself (a "relationship URL"). This URL allows the client
35-
to directly manipulate the relationship. For example, it
36-
would allow a client to remove an `author` from an
37-
`article` without deleting the people resource itself.
38-
type: string
39-
format: uri
40-
related:
41-
description: >-
42-
A link **MUST** be represented as either: a string
43-
containing the link's URL or a link object.
44-
oneOf:
45-
- description: A string containing the link's URL.
46-
type: string
47-
format: uri
48-
- type: object
49-
required:
50-
- href
51-
properties:
52-
href:
53-
description: A string containing the link's URL.
54-
type: string
55-
format: uri
56-
meta:
57-
description: >-
58-
Non-standard meta-information that can not be
59-
represented as an attribute or relationship.
60-
type: object
61-
additionalProperties: true
62-
additionalProperties: true
63-
status:
64-
description: >-
65-
The HTTP status code applicable to this problem, expressed as
66-
a string value.
67-
type: string
68-
code:
69-
description: >-
70-
An application-specific error code, expressed as a string
71-
value.
72-
type: string
73-
title:
74-
description: >-
75-
A short, human-readable summary of the problem. It **SHOULD
76-
NOT** change from occurrence to occurrence of the problem,
77-
except for purposes of localization.
78-
type: string
79-
detail:
80-
description: >-
81-
A human-readable explanation specific to this occurrence of
82-
the problem.
83-
type: string
84-
source:
85-
type: object
86-
properties:
87-
pointer:
88-
description: >-
89-
A JSON Pointer [RFC6901] to the associated entity in the
90-
request document [e.g. "/data" for a primary data object,
91-
or "/data/attributes/title" for a specific attribute].
92-
type: string
93-
parameter:
94-
description: >-
95-
A string indicating which query parameter caused the
96-
error.
97-
type: string
98-
meta:
99-
description: >-
100-
Non-standard meta-information that can not be represented as
101-
an attribute or relationship.
102-
type: object
103-
additionalProperties: true
104-
additionalProperties: false
101+
$ref: '#/components/schemas/error'
105102
uniqueItems: true
106103
meta:
107-
description: >-
108-
Non-standard meta-information that can not be represented as an
109-
attribute or relationship.
110-
type: object
111-
additionalProperties: true
104+
$ref: '#/components/schemas/meta'
112105
links:
113-
description: >-
114-
A resource object **MAY** contain references to other resource
115-
objects ("relationships"). Relationships may be to-one or to-many.
116-
Relationships can be specified by including a member in a resource's
117-
links object.
118-
type: object
119-
properties:
120-
self:
121-
description: >-
122-
A `self` member, whose value is a URL for the relationship
123-
itself (a "relationship URL"). This URL allows the client to
124-
directly manipulate the relationship. For example, it would
125-
allow a client to remove an `author` from an `article` without
126-
deleting the people resource itself.
127-
type: string
128-
format: uri
129-
related:
130-
description: >-
131-
A link **MUST** be represented as either: a string containing
132-
the link's URL or a link object.
133-
oneOf:
134-
- description: A string containing the link's URL.
135-
type: string
136-
format: uri
137-
- type: object
138-
required:
139-
- href
140-
properties:
141-
href:
142-
description: A string containing the link's URL.
143-
type: string
144-
format: uri
145-
meta:
146-
description: >-
147-
Non-standard meta-information that can not be
148-
represented as an attribute or relationship.
149-
type: object
150-
additionalProperties: true
151-
additionalProperties: true
106+
$ref: '#/components/schemas/links'
152107
additionalProperties: false
153108
PutDocumentResponse:
154109
title: Empty Schema
@@ -160,11 +115,35 @@ components:
160115
properties:
161116
SomeAttribute:
162117
type: string
118+
folder:
119+
type: object
120+
title: Folder Schema
121+
properties:
122+
id:
123+
type: string
124+
example: 3ba1c69c-3c81-4d6d-b304-873d898b2e3c
125+
format: uuid
126+
folders:
127+
type: array
128+
items:
129+
$ref: '#/components/schemas/folder'
130+
additionalProperties: false
131+
required:
132+
- id
133+
- name
134+
- folders
135+
- checklists
136+
RecursiveResponse:
137+
type: object
138+
title: Folders Response Schema
139+
properties:
140+
data:
141+
$ref: '#/components/schemas/folder'
163142
securitySchemes: {}
164143
info:
165144
title: ''
166145
description: ''
167-
version: 442d95b9-dcc5-4e6e-a354-a561b8904c08
146+
version: 249c21ac-b279-4665-8f59-4873a4c151a2
168147
paths:
169148
/create:
170149
post:
@@ -184,33 +163,3 @@ paths:
184163
application/json:
185164
schema:
186165
$ref: '#/components/schemas/ErrorResponse'
187-
parameters:
188-
- name: username
189-
in: path
190-
description: The username for a user to create
191-
required: true
192-
schema:
193-
type: string
194-
pattern: '^[-a-z0-9_]+$'
195-
- name: membershipType
196-
in: query
197-
description: The user's Membership Type
198-
required: false
199-
allowEmptyValue: false
200-
schema:
201-
type: string
202-
enum:
203-
- premium
204-
- standard
205-
- name: SessionId
206-
in: cookie
207-
description: A Session ID variable
208-
required: false
209-
schema:
210-
type: string
211-
requestBody:
212-
content:
213-
application/json:
214-
schema:
215-
$ref: '#/components/schemas/PutDocumentRequest'
216-
description: A user information object

test/project/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openapi-test-package",
33
"devDependencies": {
4-
"serverless": "^1.16.1"
4+
"serverless": "^1.39.0"
55
}
66
}

test/project/serverless.docs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ endpoints:
2323
cookieParams:
2424
- name: SessionId
2525
description: A Session ID variable
26-
schema:
26+
schema:
2727
type: string
2828
methodResponses:
2929
- statusCode: 201
@@ -60,3 +60,7 @@ documentation:
6060
properties:
6161
SomeAttribute:
6262
type: string
63+
- name: RecursiveResponse
64+
description: Recursive response example
65+
contentType: application/json
66+
schema: ${file(models/RecursiveResponse.json)}

test/project/serverless.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ provider:
55
runtime: nodejs6.10
66

77
plugins:
8-
- serverless-openapi-documentation
8+
localPath: /Users/alex/dev/serverless-openapi-documentation
9+
modules:
10+
- build
911

1012
functions:
1113
createUser:
@@ -76,3 +78,8 @@ custom:
7678
properties:
7779
SomeAttribute:
7880
type: string
81+
82+
- name: RecursiveResponse
83+
description: Recursive response example
84+
contentType: application/json
85+
schema: ${file(models/RecursiveResponse.json)}

0 commit comments

Comments
 (0)