SwaggerEditor
https://github.com/swagger-api/swagger-editor?tab=readme-ov-file#running-locally
https://github.com/swagger-api/swagger-editor?tab=readme-ov-file#docker
Example of OpenAPI/Swagger data contract
1 openapi: 3.0.4
2 info:
3 title: Swagger User - OpenAPI 3.0
4 description: |-
5 This is a sample user Server based on the OpenAPI 3.0 specification.
6
7 Some useful links:
8 - [Google](https://www.google.com)
9 termsOfService: https://swagger.io/terms/
10 contact:
11 email: apiteam@example.org
12 license:
13 name: License Apache 2.0
14 url: https://www.apache.org/licenses/LICENSE-2.0.html
15 version: 1.0.12
16 externalDocs:
17 description: Find out more about Swagger
18 url: https://swagger.io
19 servers:
20 - url: http://localhost:8181/api/v3
21 tags:
22 - name: user
23 description: Operations about user
24 paths:
25 /user/createWithList:
26 post:
27 tags:
28 - user
29 summary: Creates list of users with given input array.
30 description: Creates list of users with given input array.
31 operationId: createUsersWithListInput
32 requestBody:
33 content:
34 application/json:
35 schema:
36 type: array
37 items:
38 $ref: '#/components/schemas/User'
39 responses:
40 '200':
41 description: Successful operation
42 content:
43 application/json:
44 schema:
45 $ref: '#/components/schemas/User'
46 default:
47 description: Unexpected error
48 content:
49 application/json:
50 schema:
51 $ref: "#/components/schemas/Error"
52 /user/login:
53 get:
54 tags:
55 - user
56 summary: Logs user into the system.
57 description: Log into the system.
58 operationId: loginUser
59 parameters:
60 - name: username
61 in: query
62 description: The user name for login
63 required: true
64 schema:
65 type: string
66 - name: password
67 in: query
68 description: The password for login in clear text
69 required: true
70 schema:
71 type: string
72 responses:
73 '200':
74 description: successful operation
75 headers:
76 X-Rate-Limit:
77 description: calls per hour allowed by the user
78 schema:
79 type: integer
80 format: int32
81 X-Expires-After:
82 description: date in UTC when token expires
83 schema:
84 type: string
85 format: date-time
86 content:
87 application/json:
88 schema:
89 type: string
90 '400':
91 description: Invalid username/password supplied
92 default:
93 description: Unexpected error
94 content:
95 application/json:
96 schema:
97 $ref: "#/components/schemas/Error"
98 /user/logout:
99 get:
100 tags:
101 - user
102 summary: Logs out current logged in user session.
103 description: Log user out of the system.
104 operationId: logoutUser
105 parameters: []
106 responses:
107 '200':
108 description: successful operation
109 default:
110 description: Unexpected error
111 content:
112 application/json:
113 schema:
114 $ref: "#/components/schemas/Error"
115 /user/{username}:
116 get:
117 tags:
118 - user
119 summary: Get user by user name.
120 description: Get user detail based on username.
121 operationId: getUserByName
122 parameters:
123 - name: username
124 in: path
125 description: The name that needs to be fetched. Use user1 for testing
126 required: true
127 schema:
128 type: string
129 responses:
130 '200':
131 description: successful operation
132 content:
133 application/json:
134 schema:
135 $ref: '#/components/schemas/User'
136 '400':
137 description: Invalid username supplied
138 '404':
139 description: User not found
140 default:
141 description: Unexpected error
142 content:
143 application/json:
144 schema:
145 $ref: "#/components/schemas/Error"
146 put:
147 tags:
148 - user
149 summary: Update user resource.
150 description: This can only be done by the logged in user.
151 operationId: updateUser
152 parameters:
153 - name: username
154 in: path
155 description: name that need to be updated
156 required: true
157 schema:
158 type: string
159 requestBody:
160 description: Update an existent user in the store
161 content:
162 application/json:
163 schema:
164 $ref: '#/components/schemas/User'
165 responses:
166 '200':
167 description: successful operation
168 '400':
169 description: bad request
170 '404':
171 description: user not found
172 default:
173 description: Unexpected error
174 content:
175 application/json:
176 schema:
177 $ref: "#/components/schemas/Error"
178 delete:
179 tags:
180 - user
181 summary: Delete user resource.
182 description: This can only be done by the logged in user.
183 operationId: deleteUser
184 parameters:
185 - name: username
186 in: path
187 description: The name that needs to be deleted
188 required: true
189 schema:
190 type: string
191 responses:
192 '200':
193 description: User deleted
194 '400':
195 description: Invalid username supplied
196 '404':
197 description: User not found
198 default:
199 description: Unexpected error
200 content:
201 application/json:
202 schema:
203 $ref: "#/components/schemas/Error"
204 components:
205 schemas:
206 User:
207 type: object
208 properties:
209 id:
210 type: integer
211 format: int64
212 example: 10
213 username:
214 type: string
215 example: theUser
216 firstName:
217 type: string
218 example: John
219 lastName:
220 type: string
221 example: James
222 email:
223 type: string
224 example: john@email.com
225 password:
226 type: string
227 example: '12345'
228 phone:
229 type: string
230 example: '12345'
231 userStatus:
232 type: integer
233 description: User Status
234 format: int32
235 example: 1
236 xml:
237 name: user
238 Error:
239 type: object
240 properties:
241 code:
242 type: string
243 message:
244 type: string
245 required:
246 - code
247 - message
248 requestBodies:
249 UserArray:
250 description: List of user object
251 content:
252 application/json:
253 schema:
254 type: array
255 items:
256 $ref: '#/components/schemas/User'
- Generate server, spring, creates spring-server-generated.zip