Skip to content

Commit ff10b07

Browse files
Merge pull request #4 from dariocloudappi/develop
Develop
2 parents c04e980 + 16bff1f commit ff10b07

8 files changed

+578
-29
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
node_modules
2-
out
3-
*.yaml
4-
*.yml
2+
output
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
openapi: 3.0.3
2+
info:
3+
title: Example API
4+
description: >-
5+
Aqui la prueba de este esquema , su objetivo es ver la profundidad de los esquemas y que no se referencien.
6+
7+
Este ejemplo sirve para ver una cosa importante y esque se prioriza el ejemplo que se tiene a nivel de la esquema.
8+
El Script por defecto si encuentra un ejemplo a nivel de esquema lo coge y lo pone en el apartado de componentes y luego lo referncia.
9+
10+
version: 1.0.0
11+
paths:
12+
/users:
13+
get:
14+
summary: Retrieves a list of users
15+
operationId: getUsers
16+
responses:
17+
'200':
18+
description: Successfully retrieved list of users
19+
content:
20+
application/json:
21+
schema:
22+
type: object
23+
properties:
24+
users:
25+
type: array
26+
items:
27+
type: object
28+
properties:
29+
id:
30+
type: integer
31+
format: int64
32+
name:
33+
type: string
34+
email:
35+
type: string
36+
format: email
37+
address:
38+
type: object
39+
properties:
40+
street:
41+
type: string
42+
city:
43+
type: string
44+
contacts:
45+
type: array
46+
items:
47+
type: object
48+
properties:
49+
contactType:
50+
type: string
51+
phoneNumbers:
52+
type: array
53+
items:
54+
type: string
55+
example:
56+
- '+1234567890'
57+
- '+0987654321'
58+
example:
59+
street: '123 Main St'
60+
city: 'Springfield'
61+
contacts:
62+
- contactType: 'home'
63+
phoneNumbers:
64+
- '+1234567890'
65+
- '+0987654321'
66+
- contactType: 'work'
67+
phoneNumbers:
68+
- '+1122334455'
69+
- '+5544332211'
70+
example:
71+
users:
72+
- id: 1
73+
name: John Doe
74+
75+
address:
76+
street: '456 Elm St'
77+
city: 'Springfield'
78+
contacts:
79+
- contactType: 'home'
80+
- contactType: 'work'
81+
- id: 2
82+
name: Jane Smith
83+
84+
address:
85+
street: '789 Maple Ave'
86+
city: 'Springfield'
87+
contacts:
88+
- contactType: 'home'
89+
- contactType: 'work'
90+
'500':
91+
description: Internal server error
92+
content:
93+
application/json:
94+
schema:
95+
type: object
96+
properties:
97+
code:
98+
type: integer
99+
message:
100+
type: string
101+
example:
102+
code: 500
103+
message: Internal server error
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
openapi: 3.0.3
2+
info:
3+
title: User API
4+
description: >-
5+
Esto es una combinacion de varios esquemas que se encuentran referenciados y que se han generado a partir del script
6+
Aqui lo que se ha hecho es coger los esquemas que se encuentran referenciados y se han generado los ejemplos para cada uno de ellos
7+
"UserBase" -> Se genera una propiedad id dentro de ella un array de string ids con el ejemplo que se tiene a nivel de la propiedad ids.
8+
9+
Esto ha sido un ejemplo para ver el comportamiento que se tiene con la anidacion de objetos y arrays.
10+
version: 1.0.0
11+
paths:
12+
/user:
13+
get:
14+
summary: Retrieve user information
15+
responses:
16+
'200':
17+
description: User information retrieved successfully
18+
content:
19+
application/json:
20+
schema:
21+
allOf:
22+
- $ref: '#/components/schemas/UserBase'
23+
- $ref: '#/components/schemas/UserStatus'
24+
- $ref: '#/components/schemas/UserContact'
25+
- $ref: '#/components/schemas/UserRoles'
26+
examples:
27+
GeneratedExample94D4:
28+
$ref: '#/components/examples/GeneratedExample94D4'
29+
components:
30+
schemas:
31+
UserBase:
32+
type: object
33+
properties:
34+
id:
35+
type: object
36+
properties:
37+
ids:
38+
type: array
39+
items:
40+
type: string
41+
example:
42+
- 12345
43+
- 23456
44+
name:
45+
type: string
46+
example: John Doe
47+
UserStatus:
48+
type: object
49+
properties:
50+
status:
51+
type: string
52+
example: active
53+
lastLogin:
54+
type: string
55+
format: date-time
56+
example: '2023-05-23T08:30:00Z'
57+
UserContact:
58+
type: object
59+
properties:
60+
email:
61+
type: string
62+
format: email
63+
64+
phone:
65+
type: string
66+
example: '+1234567890'
67+
UserRoles:
68+
type: object
69+
properties:
70+
roles:
71+
type: array
72+
items:
73+
type: string
74+
example: admin
75+
example:
76+
roles:
77+
- admin
78+
- user
79+
examples:
80+
GeneratedExample94D4:
81+
summary: Example generated by script
82+
value:
83+
id:
84+
ids:
85+
- 12345
86+
- 23456
87+
name: John Doe
88+
status: active
89+
lastLogin: '2023-05-23T08:30:00Z'
90+
91+
phone: '+1234567890'
92+
roles:
93+
- admin
94+
- user
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
openapi: 3.0.3
2+
info:
3+
title: Example API
4+
description: This is an example API that uses inline schemas and examples with nested arrays.
5+
version: 1.0.0
6+
paths:
7+
/users:
8+
get:
9+
summary: Retrieves a list of users
10+
operationId: getUsers
11+
responses:
12+
'200':
13+
description: Successfully retrieved list of users
14+
content:
15+
application/json:
16+
schema:
17+
type: object
18+
properties:
19+
users:
20+
type: array
21+
items:
22+
type: object
23+
properties:
24+
id:
25+
type: integer
26+
format: int64
27+
name:
28+
type: string
29+
email:
30+
type: string
31+
format: email
32+
address:
33+
type: object
34+
properties:
35+
street:
36+
type: string
37+
city:
38+
type: string
39+
contacts:
40+
type: array
41+
items:
42+
type: object
43+
properties:
44+
contactType:
45+
type: string
46+
phoneNumbers:
47+
type: array
48+
items:
49+
type: string
50+
example:
51+
- '+1234567890'
52+
- '+0987654321'
53+
example:
54+
street: '123 Main St'
55+
city: 'Springfield'
56+
contacts:
57+
- contactType: 'home'
58+
phoneNumbers:
59+
- '+1234567890'
60+
- '+0987654321'
61+
- contactType: 'work'
62+
phoneNumbers:
63+
- '+1122334455'
64+
- '+5544332211'
65+
example:
66+
users:
67+
- id: 1
68+
name: John Doe
69+
70+
address:
71+
street: '456 Elm St'
72+
city: 'Springfield'
73+
contacts:
74+
- contactType: 'home'
75+
phoneNumbers:
76+
- '+1122334455'
77+
- contactType: 'work'
78+
phoneNumbers:
79+
- '+9988776655'
80+
- id: 2
81+
name: Jane Smith
82+
83+
address:
84+
street: '789 Maple Ave'
85+
city: 'Springfield'
86+
contacts:
87+
- contactType: 'home'
88+
phoneNumbers:
89+
- '+1231231234'
90+
- '+4321432143'
91+
- contactType: 'work'
92+
phoneNumbers:
93+
- '+5555555555'
94+
- '+6666666666'
95+
'500':
96+
description: Internal server error
97+
content:
98+
application/json:
99+
schema:
100+
type: object
101+
properties:
102+
code:
103+
type: integer
104+
message:
105+
type: string
106+
example:
107+
code: 500
108+
message: Internal server error

0 commit comments

Comments
 (0)