Skip to content

Commit 680ed27

Browse files
committed
Fix CI
1 parent 3eb80bd commit 680ed27

3 files changed

Lines changed: 262 additions & 4 deletions

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

cmd/app/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//go:generate go tool swag init -g main.go -o ../../ -ot yaml --v3.1 --parseDependency
2-
//go:generate mv ../../swagger.yaml ../../openapi-v3.yaml
1+
//go:generate sh -c "go tool swag init -d ../../ -g cmd/app/main.go -o ../../ -ot yaml --v3.1 --parseDependency && mv ../../swagger.yaml ../../openapi-v3.yaml"
32

43
package main
54

openapi-v3.yaml

Lines changed: 260 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,52 @@
1-
components: {}
1+
components:
2+
schemas:
3+
form.BookForm:
4+
properties:
5+
author:
6+
maxLength: 255
7+
type: string
8+
description:
9+
type: string
10+
image_url:
11+
type: string
12+
published_date:
13+
type: string
14+
title:
15+
maxLength: 255
16+
type: string
17+
required:
18+
- author
19+
- published_date
20+
- title
21+
type: object
22+
model.BookDTO:
23+
properties:
24+
author:
25+
type: string
26+
description:
27+
type: string
28+
id:
29+
type: string
30+
image_url:
31+
type: string
32+
published_date:
33+
type: string
34+
title:
35+
type: string
36+
type: object
37+
myapp_pkg_errors.Error:
38+
properties:
39+
error:
40+
type: string
41+
type: object
42+
myapp_pkg_errors.Errors:
43+
properties:
44+
errors:
45+
items:
46+
type: string
47+
type: array
48+
uniqueItems: false
49+
type: object
250
externalDocs:
351
description: ""
452
url: ""
@@ -13,6 +61,216 @@ info:
1361
title: MYAPP API
1462
version: "1.0"
1563
openapi: 3.1.0
16-
paths: {}
64+
paths:
65+
/books:
66+
get:
67+
description: List books
68+
parameters:
69+
- description: Page number for pagination
70+
in: query
71+
name: page
72+
schema:
73+
default: 1
74+
minimum: 1
75+
type: integer
76+
- description: Number of items per page
77+
in: query
78+
name: pageSize
79+
schema:
80+
default: 10
81+
maximum: 100
82+
minimum: 1
83+
type: integer
84+
requestBody:
85+
content:
86+
application/json:
87+
schema:
88+
type: object
89+
responses:
90+
"200":
91+
content:
92+
application/json:
93+
schema:
94+
items:
95+
$ref: '#/components/schemas/model.BookDTO'
96+
type: array
97+
description: OK
98+
"500":
99+
content:
100+
application/json:
101+
schema:
102+
$ref: '#/components/schemas/myapp_pkg_errors.Error'
103+
description: Internal Server Error
104+
summary: List books
105+
tags:
106+
- books
107+
post:
108+
description: Create book
109+
requestBody:
110+
content:
111+
application/json:
112+
schema:
113+
oneOf:
114+
- type: object
115+
- $ref: '#/components/schemas/form.BookForm'
116+
description: Book form
117+
summary: body
118+
description: Book form
119+
required: true
120+
responses:
121+
"201":
122+
content:
123+
application/json:
124+
schema:
125+
$ref: '#/components/schemas/model.BookDTO'
126+
description: Created
127+
"400":
128+
content:
129+
application/json:
130+
schema:
131+
$ref: '#/components/schemas/myapp_pkg_errors.Error'
132+
description: Bad Request
133+
"422":
134+
content:
135+
application/json:
136+
schema:
137+
$ref: '#/components/schemas/myapp_pkg_errors.Errors'
138+
description: Unprocessable Entity
139+
"500":
140+
content:
141+
application/json:
142+
schema:
143+
$ref: '#/components/schemas/myapp_pkg_errors.Error'
144+
description: Internal Server Error
145+
summary: Create book
146+
tags:
147+
- books
148+
/books/{id}:
149+
delete:
150+
description: Delete book
151+
parameters:
152+
- description: Book ID
153+
in: path
154+
name: id
155+
required: true
156+
schema:
157+
type: string
158+
requestBody:
159+
content:
160+
application/json:
161+
schema:
162+
type: object
163+
responses:
164+
"200":
165+
content:
166+
application/json:
167+
schema:
168+
type: object
169+
description: OK
170+
"400":
171+
content:
172+
application/json:
173+
schema:
174+
$ref: '#/components/schemas/myapp_pkg_errors.Error'
175+
description: Bad Request
176+
"404":
177+
description: Not Found
178+
"500":
179+
content:
180+
application/json:
181+
schema:
182+
$ref: '#/components/schemas/myapp_pkg_errors.Error'
183+
description: Internal Server Error
184+
summary: Delete book
185+
tags:
186+
- books
187+
get:
188+
description: Read book
189+
parameters:
190+
- description: Book ID
191+
in: path
192+
name: id
193+
required: true
194+
schema:
195+
type: string
196+
requestBody:
197+
content:
198+
application/json:
199+
schema:
200+
type: object
201+
responses:
202+
"200":
203+
content:
204+
application/json:
205+
schema:
206+
$ref: '#/components/schemas/model.BookDTO'
207+
description: OK
208+
"400":
209+
content:
210+
application/json:
211+
schema:
212+
$ref: '#/components/schemas/myapp_pkg_errors.Error'
213+
description: Bad Request
214+
"404":
215+
description: Not Found
216+
"500":
217+
content:
218+
application/json:
219+
schema:
220+
$ref: '#/components/schemas/myapp_pkg_errors.Error'
221+
description: Internal Server Error
222+
summary: Read book
223+
tags:
224+
- books
225+
put:
226+
description: Update book
227+
parameters:
228+
- description: Book ID
229+
in: path
230+
name: id
231+
required: true
232+
schema:
233+
type: string
234+
requestBody:
235+
content:
236+
application/json:
237+
schema:
238+
oneOf:
239+
- type: object
240+
- $ref: '#/components/schemas/form.BookForm'
241+
description: Book form
242+
summary: body
243+
description: Book form
244+
required: true
245+
responses:
246+
"200":
247+
content:
248+
application/json:
249+
schema:
250+
$ref: '#/components/schemas/model.BookDTO'
251+
description: OK
252+
"400":
253+
content:
254+
application/json:
255+
schema:
256+
$ref: '#/components/schemas/myapp_pkg_errors.Error'
257+
description: Bad Request
258+
"404":
259+
description: Not Found
260+
"422":
261+
content:
262+
application/json:
263+
schema:
264+
$ref: '#/components/schemas/myapp_pkg_errors.Errors'
265+
description: Unprocessable Entity
266+
"500":
267+
content:
268+
application/json:
269+
schema:
270+
$ref: '#/components/schemas/myapp_pkg_errors.Error'
271+
description: Internal Server Error
272+
summary: Update book
273+
tags:
274+
- books
17275
servers:
18276
- url: localhost:8080/v1

0 commit comments

Comments
 (0)