@grafana/openapi-to-k6 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/.github/workflows/tests.yaml +1 -0
  2. package/README.md +10 -4
  3. package/dist/cli.js +27 -12
  4. package/dist/constants.js +7 -3
  5. package/dist/errors.js +10 -0
  6. package/dist/generator/index.js +50 -3
  7. package/dist/generator/k6Client.js +5 -55
  8. package/dist/generator/k6ScriptBuilder.js +256 -0
  9. package/dist/helper.js +32 -0
  10. package/examples/basic_schema/single/k6-script.sample.ts +3 -2
  11. package/examples/basic_schema/single/simpleAPI.ts +1 -1
  12. package/examples/basic_schema/split/k6-script.sample.ts +3 -2
  13. package/examples/basic_schema/split/simpleAPI.schemas.ts +1 -1
  14. package/examples/basic_schema/split/simpleAPI.ts +1 -1
  15. package/examples/basic_schema/tags/default.ts +1 -1
  16. package/examples/basic_schema/tags/k6-script.sample.ts +4 -3
  17. package/examples/basic_schema/tags/simpleAPI.schemas.ts +1 -1
  18. package/examples/form_data_schema/schema.json +6 -3
  19. package/examples/form_data_schema/single/formDataAPI.ts +1 -1
  20. package/examples/form_data_schema/single/k6-script.sample.ts +10 -2
  21. package/examples/form_data_schema/split/formDataAPI.schemas.ts +1 -1
  22. package/examples/form_data_schema/split/formDataAPI.ts +1 -1
  23. package/examples/form_data_schema/split/k6-script.sample.ts +10 -2
  24. package/examples/form_data_schema/tags/default.ts +1 -1
  25. package/examples/form_data_schema/tags/formDataAPI.schemas.ts +1 -1
  26. package/examples/form_data_schema/tags/k6-script.sample.ts +11 -3
  27. package/examples/form_url_encoded_data_schema/schema.json +6 -3
  28. package/examples/form_url_encoded_data_schema/single/formURLEncodedAPI.ts +1 -1
  29. package/examples/form_url_encoded_data_schema/single/k6-script.sample.ts +11 -2
  30. package/examples/form_url_encoded_data_schema/split/formURLEncodedAPI.schemas.ts +1 -1
  31. package/examples/form_url_encoded_data_schema/split/formURLEncodedAPI.ts +1 -1
  32. package/examples/form_url_encoded_data_schema/split/k6-script.sample.ts +11 -2
  33. package/examples/form_url_encoded_data_schema/tags/default.ts +1 -1
  34. package/examples/form_url_encoded_data_schema/tags/formURLEncodedAPI.schemas.ts +1 -1
  35. package/examples/form_url_encoded_data_schema/tags/k6-script.sample.ts +12 -3
  36. package/examples/form_url_encoded_data_with_query_params_schema/schema.json +8 -4
  37. package/examples/form_url_encoded_data_with_query_params_schema/single/formURLEncodedAPIWithQueryParameters.ts +1 -1
  38. package/examples/form_url_encoded_data_with_query_params_schema/single/k6-script.sample.ts +19 -6
  39. package/examples/form_url_encoded_data_with_query_params_schema/split/formURLEncodedAPIWithQueryParameters.schemas.ts +1 -1
  40. package/examples/form_url_encoded_data_with_query_params_schema/split/formURLEncodedAPIWithQueryParameters.ts +1 -1
  41. package/examples/form_url_encoded_data_with_query_params_schema/split/k6-script.sample.ts +19 -6
  42. package/examples/form_url_encoded_data_with_query_params_schema/tags/default.ts +1 -1
  43. package/examples/form_url_encoded_data_with_query_params_schema/tags/formURLEncodedAPIWithQueryParameters.schemas.ts +1 -1
  44. package/examples/form_url_encoded_data_with_query_params_schema/tags/k6-script.sample.ts +14 -3
  45. package/examples/get_request_with_path_parameters_schema/schema.json +2 -1
  46. package/examples/get_request_with_path_parameters_schema/single/k6-script.sample.ts +6 -2
  47. package/examples/get_request_with_path_parameters_schema/single/simpleAPI.ts +1 -1
  48. package/examples/get_request_with_path_parameters_schema/split/k6-script.sample.ts +6 -2
  49. package/examples/get_request_with_path_parameters_schema/split/simpleAPI.schemas.ts +1 -1
  50. package/examples/get_request_with_path_parameters_schema/split/simpleAPI.ts +1 -1
  51. package/examples/get_request_with_path_parameters_schema/tags/default.ts +1 -1
  52. package/examples/get_request_with_path_parameters_schema/tags/k6-script.sample.ts +7 -3
  53. package/examples/get_request_with_path_parameters_schema/tags/simpleAPI.schemas.ts +1 -1
  54. package/examples/headers_schema/schema.json +2 -1
  55. package/examples/headers_schema/single/headerDemoAPI.ts +1 -1
  56. package/examples/headers_schema/single/k6-script.sample.ts +15 -4
  57. package/examples/headers_schema/split/headerDemoAPI.schemas.ts +1 -1
  58. package/examples/headers_schema/split/headerDemoAPI.ts +1 -1
  59. package/examples/headers_schema/split/k6-script.sample.ts +15 -4
  60. package/examples/headers_schema/tags/default.ts +1 -1
  61. package/examples/headers_schema/tags/headerDemoAPI.schemas.ts +1 -1
  62. package/examples/headers_schema/tags/k6-script.sample.ts +16 -5
  63. package/examples/no_title_schema/single/k6-script.sample.ts +3 -2
  64. package/examples/no_title_schema/single/k6Client.ts +1 -1
  65. package/examples/no_title_schema/split/k6-script.sample.ts +3 -2
  66. package/examples/no_title_schema/split/k6Client.schemas.ts +1 -1
  67. package/examples/no_title_schema/split/k6Client.ts +1 -1
  68. package/examples/no_title_schema/tags/default.ts +1 -1
  69. package/examples/no_title_schema/tags/k6-script.sample.ts +4 -3
  70. package/examples/no_title_schema/tags/k6Client.schemas.ts +1 -1
  71. package/examples/post_request_with_query_params/schema.json +14 -7
  72. package/examples/post_request_with_query_params/single/exampleAPI.ts +1 -1
  73. package/examples/post_request_with_query_params/single/k6-script.sample.ts +11 -2
  74. package/examples/post_request_with_query_params/split/exampleAPI.schemas.ts +1 -1
  75. package/examples/post_request_with_query_params/split/exampleAPI.ts +1 -1
  76. package/examples/post_request_with_query_params/split/k6-script.sample.ts +11 -2
  77. package/examples/post_request_with_query_params/tags/default.ts +1 -1
  78. package/examples/post_request_with_query_params/tags/exampleAPI.schemas.ts +1 -1
  79. package/examples/post_request_with_query_params/tags/k6-script.sample.ts +12 -3
  80. package/examples/query_params_schema/schema.json +20 -10
  81. package/examples/query_params_schema/single/exampleAPI.ts +1 -1
  82. package/examples/query_params_schema/single/k6-script.sample.ts +8 -2
  83. package/examples/query_params_schema/split/exampleAPI.schemas.ts +1 -1
  84. package/examples/query_params_schema/split/exampleAPI.ts +1 -1
  85. package/examples/query_params_schema/split/k6-script.sample.ts +8 -2
  86. package/examples/query_params_schema/tags/default.ts +1 -1
  87. package/examples/query_params_schema/tags/exampleAPI.schemas.ts +1 -1
  88. package/examples/query_params_schema/tags/k6-script.sample.ts +9 -3
  89. package/examples/simple_post_request_schema/schema.json +30 -15
  90. package/examples/simple_post_request_schema/single/exampleAPI.ts +1 -1
  91. package/examples/simple_post_request_schema/single/k6-script.sample.ts +16 -2
  92. package/examples/simple_post_request_schema/split/exampleAPI.schemas.ts +1 -1
  93. package/examples/simple_post_request_schema/split/exampleAPI.ts +1 -1
  94. package/examples/simple_post_request_schema/split/k6-script.sample.ts +16 -2
  95. package/examples/simple_post_request_schema/tags/default.ts +1 -1
  96. package/examples/simple_post_request_schema/tags/exampleAPI.schemas.ts +1 -1
  97. package/examples/simple_post_request_schema/tags/k6-script.sample.ts +17 -3
  98. package/package.json +3 -1
  99. package/src/cli.ts +32 -14
  100. package/src/constants.ts +7 -3
  101. package/src/errors.ts +6 -0
  102. package/src/generator/index.ts +67 -2
  103. package/src/generator/k6Client.ts +3 -72
  104. package/src/generator/k6ScriptBuilder.ts +328 -0
  105. package/src/helper.ts +40 -0
  106. package/src/type.d.ts +1 -0
  107. package/tests/e2e/schema.json +136 -18
  108. package/tests/e2e/single-tag-filter/k6Script.ts +50 -0
  109. package/tests/e2e/tags/k6Script.ts +3 -3
  110. package/tests/functional-tests/helper.ts +16 -0
  111. package/tests/functional-tests/{generator.test.ts → test-generator/generator.test.ts} +12 -21
  112. package/tests/functional-tests/test-sample-k6-scripts/fixtures/schema_using_ref_models.json +394 -0
  113. package/tests/functional-tests/test-sample-k6-scripts/fixtures/schema_with_examples.json +416 -0
  114. package/tests/functional-tests/test-sample-k6-scripts/fixtures/schema_with_no_variables.json +32 -0
  115. package/tests/functional-tests/test-sample-k6-scripts/sampleK6Scripts.test.ts +248 -0
  116. package/tests/functional-tests/test-tags-filtering/fixtures/tags_filtering.json +141 -0
  117. package/tests/functional-tests/test-tags-filtering/tagsFiltering.test.ts +166 -0
  118. package/tests/helper.test.ts +59 -0
  119. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/basic_schema.json +0 -0
  120. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/form_data_schema.json +0 -0
  121. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/form_url_encoded_data_schema.json +0 -0
  122. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/form_url_encoded_data_with_query_params_schema.json +0 -0
  123. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/get_request_with_path_parameters_schema.json +0 -0
  124. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/headers_schema.json +0 -0
  125. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/no_title_schema.json +0 -0
  126. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/post_request_with_query_params.json +0 -0
  127. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/query_params_schema.json +0 -0
  128. /package/tests/functional-tests/{fixtures/schemas → test-generator/fixtures}/simple_post_request_schema.json +0 -0
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable import/no-unresolved */
2
2
  import { check } from 'k6'
3
- import { DefaultClient } from './default.ts'
4
3
  import { ItemsFormClient } from './items-form.ts'
4
+ import { ItemsHeaderClient } from './items-header.ts'
5
5
  import { ItemsClient } from './items.ts'
6
6
 
7
7
  /* eslint-enable import/no-unresolved */
@@ -9,7 +9,7 @@ import { ItemsClient } from './items.ts'
9
9
  const baseUrl = 'http://localhost:3000'
10
10
  const itemsClient = new ItemsClient({ baseUrl })
11
11
  const itemFormClient = new ItemsFormClient({ baseUrl })
12
- const defaultClient = new DefaultClient({ baseUrl })
12
+ const itemsHeaderClient = new ItemsHeaderClient({ baseUrl })
13
13
 
14
14
  export const options = {
15
15
  thresholds: {
@@ -98,7 +98,7 @@ export default function () {
98
98
  // Items form client call end
99
99
 
100
100
  // Default client call start
101
- const getItemsHeaderResponseData = defaultClient.getItemsHeader({
101
+ const getItemsHeaderResponseData = itemsHeaderClient.getItemsHeader({
102
102
  id: 'test',
103
103
  })
104
104
  checkResponseStatus(getItemsHeaderResponseData.response, 200)
@@ -0,0 +1,16 @@
1
+ import fs from 'fs'
2
+ import { promisify } from 'util'
3
+
4
+ export const writeFile = promisify(fs.writeFile)
5
+ export const readFile = promisify(fs.readFile)
6
+ export const mkdtemp = promisify(fs.mkdtemp)
7
+ export const rmdir = promisify(fs.rmdir)
8
+
9
+ export const loadFixture = (filePath: string) => {
10
+ const data = fs.readFileSync(filePath, 'utf-8')
11
+ return JSON.parse(data)
12
+ }
13
+
14
+ export const replaceSpacesAndNewLineToSingleSpace = (input: string): string => {
15
+ return input.replace(/\s+/g, ' ')
16
+ }
@@ -1,7 +1,6 @@
1
1
  import fs from 'fs'
2
2
  import os from 'os'
3
3
  import path from 'path'
4
- import { promisify } from 'util'
5
4
  import {
6
5
  afterAll,
7
6
  afterEach,
@@ -11,21 +10,17 @@ import {
11
10
  expect,
12
11
  it,
13
12
  } from 'vitest'
14
- import { Mode } from '../../src/constants'
15
- import generator from '../../src/generator'
13
+ import { Mode } from '../../../src/constants'
14
+ import generator from '../../../src/generator'
16
15
 
17
- const writeFile = promisify(fs.writeFile)
18
- const readFile = promisify(fs.readFile)
19
- const mkdtemp = promisify(fs.mkdtemp)
20
- const rmdir = promisify(fs.rmdir)
21
-
22
- const fixturesDir = path.join(__dirname, 'fixtures', 'schemas')
23
-
24
- const loadFixture = (filename: string) => {
25
- const filePath = path.join(fixturesDir, filename)
26
- const data = fs.readFileSync(filePath, 'utf-8')
27
- return JSON.parse(data)
28
- }
16
+ import {
17
+ loadFixture,
18
+ mkdtemp,
19
+ readFile,
20
+ replaceSpacesAndNewLineToSingleSpace,
21
+ rmdir,
22
+ writeFile,
23
+ } from '../helper'
29
24
 
30
25
  const commonSubstringsForAllSDK = [
31
26
  'Automatically generated by',
@@ -38,13 +33,9 @@ const commonSubstringsForAllSDK = [
38
33
 
39
34
  const commonSubstringsForK6SampleScript = [`const baseUrl = "<BASE_URL>";`]
40
35
 
41
- function replaceSpacesAndNewLineToSingleSpace(input: string): string {
42
- return input.replace(/\s+/g, ' ')
43
- }
44
-
45
36
  describe('generator', () => {
46
37
  let tempDir: string, schemaDirectory: string
47
- const allFixtures = fs.readdirSync(fixturesDir)
38
+ const allFixtures = fs.readdirSync(path.join(__dirname, 'fixtures'))
48
39
 
49
40
  beforeAll(async () => {
50
41
  tempDir = await mkdtemp(path.join(os.tmpdir(), 'sdk-generator-'))
@@ -57,7 +48,7 @@ describe('generator', () => {
57
48
  for (const fixtureName of allFixtures) {
58
49
  describe(`test ${fixtureName} OpenAPI schema`, () => {
59
50
  let openApiPath: string, generatedSchemaPath: string
60
- const fixture = loadFixture(fixtureName)
51
+ const fixture = loadFixture(path.join(__dirname, 'fixtures', fixtureName))
61
52
 
62
53
  beforeEach(async () => {
63
54
  schemaDirectory = await mkdtemp(
@@ -0,0 +1,394 @@
1
+ {
2
+ "openapi": "3.0.3",
3
+ "info": {
4
+ "title": "Comprehensive API",
5
+ "version": "1.0.0",
6
+ "description": "API supporting various HTTP methods with query, path parameters, and headers"
7
+ },
8
+ "components": {
9
+ "schemas": {
10
+ "ItemBase": {
11
+ "type": "object",
12
+ "properties": {
13
+ "name": {
14
+ "type": "string",
15
+ "example": "Sample Item"
16
+ },
17
+ "description": {
18
+ "type": "string",
19
+ "example": "This is a sample description for the item."
20
+ }
21
+ }
22
+ },
23
+ "ItemId": {
24
+ "type": "string",
25
+ "example": "12345-getItemById"
26
+ },
27
+ "UpdatedItem": {
28
+ "type": "object",
29
+ "properties": {
30
+ "name": {
31
+ "type": "string",
32
+ "example": "Updated Item Name"
33
+ },
34
+ "description": {
35
+ "type": "string",
36
+ "example": "Updated description for the item."
37
+ }
38
+ }
39
+ },
40
+ "PatchItem": {
41
+ "type": "object",
42
+ "properties": {
43
+ "name": {
44
+ "type": "string",
45
+ "example": "Partially Updated Item Name"
46
+ }
47
+ }
48
+ },
49
+ "FormUrlEncodedItem": {
50
+ "type": "object",
51
+ "properties": {
52
+ "name": {
53
+ "type": "string",
54
+ "example": "Form Encoded Item"
55
+ },
56
+ "description": {
57
+ "type": "string",
58
+ "example": "Description for form-urlencoded item."
59
+ }
60
+ },
61
+ "required": ["name"]
62
+ },
63
+ "FormDataItem": {
64
+ "type": "object",
65
+ "properties": {
66
+ "name": {
67
+ "type": "string",
68
+ "example": "Form Data Item"
69
+ }
70
+ },
71
+ "required": ["file", "name"]
72
+ },
73
+ "UserPost": {
74
+ "type": "object",
75
+ "properties": {
76
+ "title": {
77
+ "type": "string"
78
+ },
79
+ "content": {
80
+ "type": "string"
81
+ }
82
+ }
83
+ }
84
+ },
85
+ "parameters": {
86
+ "itemIdPath": {
87
+ "name": "id",
88
+ "in": "path",
89
+ "required": true,
90
+ "description": "ID of the item to retrieve",
91
+ "schema": {
92
+ "$ref": "#/components/schemas/ItemId"
93
+ }
94
+ },
95
+ "detailQuery": {
96
+ "name": "detail",
97
+ "in": "query",
98
+ "required": false,
99
+ "description": "Whether to return detailed information",
100
+ "schema": {
101
+ "type": "boolean",
102
+ "default": false,
103
+ "example": true
104
+ }
105
+ },
106
+ "userId": {
107
+ "name": "userId",
108
+ "in": "path",
109
+ "required": true,
110
+ "schema": {
111
+ "type": "string"
112
+ }
113
+ },
114
+ "postId": {
115
+ "name": "postId",
116
+ "in": "path",
117
+ "required": true,
118
+ "schema": {
119
+ "type": "string"
120
+ }
121
+ },
122
+ "clientIdHeader": {
123
+ "name": "X-Client-ID",
124
+ "in": "header",
125
+ "description": "Client ID for the request",
126
+ "required": true,
127
+ "schema": {
128
+ "type": "string",
129
+ "example": "client-123"
130
+ }
131
+ },
132
+ "requestIdHeader": {
133
+ "name": "X-Request-ID",
134
+ "in": "header",
135
+ "description": "Unique request identifier",
136
+ "required": false,
137
+ "schema": {
138
+ "type": "string",
139
+ "example": "req-56789"
140
+ }
141
+ },
142
+ "authTokenHeader": {
143
+ "name": "X-Auth-Token",
144
+ "in": "header",
145
+ "description": "Authentication token",
146
+ "required": true,
147
+ "schema": {
148
+ "type": "string",
149
+ "example": "Bearer abcdef12345"
150
+ }
151
+ },
152
+ "correlationIdHeader": {
153
+ "name": "X-Correlation-ID",
154
+ "in": "header",
155
+ "description": "Correlation ID for tracking requests",
156
+ "required": true,
157
+ "schema": {
158
+ "type": "string",
159
+ "example": "correlation-12345"
160
+ }
161
+ },
162
+ "optionalHeader": {
163
+ "name": "X-Optional-Header",
164
+ "in": "header",
165
+ "description": "Optional header",
166
+ "required": false,
167
+ "schema": {
168
+ "type": "string",
169
+ "example": "optional-header-value"
170
+ }
171
+ }
172
+ }
173
+ },
174
+ "paths": {
175
+ "/items/{id}": {
176
+ "get": {
177
+ "tags": ["Items"],
178
+ "summary": "Get an item by ID",
179
+ "parameters": [
180
+ { "$ref": "#/components/parameters/itemIdPath" },
181
+ { "$ref": "#/components/parameters/detailQuery" }
182
+ ],
183
+ "responses": {
184
+ "200": {
185
+ "description": "Successful response"
186
+ }
187
+ }
188
+ },
189
+ "post": {
190
+ "tags": ["Items"],
191
+ "summary": "Create an item by ID",
192
+ "parameters": [{ "$ref": "#/components/parameters/itemIdPath" }],
193
+ "requestBody": {
194
+ "required": true,
195
+ "content": {
196
+ "application/json": {
197
+ "schema": {
198
+ "$ref": "#/components/schemas/ItemBase"
199
+ }
200
+ }
201
+ }
202
+ },
203
+ "responses": {
204
+ "201": {
205
+ "description": "Item created successfully"
206
+ }
207
+ }
208
+ },
209
+ "put": {
210
+ "tags": ["Items"],
211
+ "summary": "Update an item by ID",
212
+ "parameters": [{ "$ref": "#/components/parameters/itemIdPath" }],
213
+ "requestBody": {
214
+ "required": true,
215
+ "content": {
216
+ "application/json": {
217
+ "schema": {
218
+ "$ref": "#/components/schemas/UpdatedItem"
219
+ }
220
+ }
221
+ }
222
+ },
223
+ "responses": {
224
+ "200": {
225
+ "description": "Item updated successfully"
226
+ }
227
+ }
228
+ },
229
+ "patch": {
230
+ "tags": ["Items"],
231
+ "summary": "Partially update an item by ID",
232
+ "parameters": [{ "$ref": "#/components/parameters/itemIdPath" }],
233
+ "requestBody": {
234
+ "required": true,
235
+ "content": {
236
+ "application/json": {
237
+ "schema": {
238
+ "$ref": "#/components/schemas/PatchItem"
239
+ }
240
+ }
241
+ }
242
+ },
243
+ "responses": {
244
+ "200": {
245
+ "description": "Item partially updated"
246
+ }
247
+ }
248
+ },
249
+ "delete": {
250
+ "tags": ["Items"],
251
+ "summary": "Delete an item by ID",
252
+ "parameters": [{ "$ref": "#/components/parameters/itemIdPath" }],
253
+ "responses": {
254
+ "204": {
255
+ "description": "Item deleted successfully"
256
+ }
257
+ }
258
+ },
259
+ "head": {
260
+ "tags": ["Items"],
261
+ "summary": "Check if item exists",
262
+ "parameters": [{ "$ref": "#/components/parameters/itemIdPath" }],
263
+ "responses": {
264
+ "200": {
265
+ "description": "Item exists"
266
+ },
267
+ "404": {
268
+ "description": "Item not found"
269
+ }
270
+ }
271
+ }
272
+ },
273
+ "/items-form-url-encoded": {
274
+ "post": {
275
+ "tags": ["ItemsForm", "Items"],
276
+ "summary": "Create an item using form-urlencoded data",
277
+ "requestBody": {
278
+ "required": true,
279
+ "content": {
280
+ "application/x-www-form-urlencoded": {
281
+ "schema": {
282
+ "$ref": "#/components/schemas/FormUrlEncodedItem"
283
+ }
284
+ }
285
+ }
286
+ },
287
+ "responses": {
288
+ "201": {
289
+ "description": "Item created successfully"
290
+ }
291
+ }
292
+ }
293
+ },
294
+ "/items-form-data": {
295
+ "post": {
296
+ "tags": ["ItemsForm", "Items"],
297
+ "summary": "Create an item using form-data",
298
+ "requestBody": {
299
+ "required": true,
300
+ "content": {
301
+ "multipart/form-data": {
302
+ "schema": {
303
+ "$ref": "#/components/schemas/FormDataItem"
304
+ }
305
+ }
306
+ }
307
+ },
308
+ "responses": {
309
+ "201": {
310
+ "description": "Item created with file upload"
311
+ }
312
+ }
313
+ }
314
+ },
315
+ "/items-header": {
316
+ "get": {
317
+ "tags": ["ItemsHeader"],
318
+ "summary": "Get an item with custom headers",
319
+ "parameters": [
320
+ {
321
+ "name": "id",
322
+ "in": "query",
323
+ "required": true,
324
+ "description": "ID of the item to retrieve",
325
+ "schema": {
326
+ "type": "string",
327
+ "example": "123450-getItemByIdWithHeader"
328
+ }
329
+ },
330
+ { "$ref": "#/components/parameters/clientIdHeader" },
331
+ { "$ref": "#/components/parameters/requestIdHeader" }
332
+ ],
333
+ "responses": {
334
+ "200": {
335
+ "description": "Item retrieved successfully"
336
+ }
337
+ },
338
+ "requestBody": {
339
+ "required": false
340
+ }
341
+ }
342
+ },
343
+ "/users/{userId}/posts/{postId}": {
344
+ "get": {
345
+ "operationId": "getUserPost",
346
+ "parameters": [
347
+ { "$ref": "#/components/parameters/userId" },
348
+ { "$ref": "#/components/parameters/postId" }
349
+ ],
350
+ "responses": {
351
+ "200": {
352
+ "description": "Success",
353
+ "content": {
354
+ "application/json": {
355
+ "schema": {
356
+ "$ref": "#/components/schemas/UserPost"
357
+ }
358
+ }
359
+ }
360
+ }
361
+ }
362
+ }
363
+ },
364
+ "/items-new-mandatory-headers": {
365
+ "get": {
366
+ "tags": ["ItemsHeader"],
367
+ "summary": "Retrieve a new item with mandatory headers",
368
+ "parameters": [
369
+ {
370
+ "name": "itemId",
371
+ "in": "query",
372
+ "required": true,
373
+ "description": "ID of the item to retrieve",
374
+ "schema": {
375
+ "type": "string",
376
+ "example": "67890"
377
+ }
378
+ },
379
+ { "$ref": "#/components/parameters/authTokenHeader" },
380
+ { "$ref": "#/components/parameters/correlationIdHeader" },
381
+ { "$ref": "#/components/parameters/optionalHeader" }
382
+ ],
383
+ "responses": {
384
+ "200": {
385
+ "description": "New item retrieved successfully"
386
+ },
387
+ "400": {
388
+ "description": "Invalid request"
389
+ }
390
+ }
391
+ }
392
+ }
393
+ }
394
+ }