Skip to content

Commit 30b5b6a

Browse files
authored
Merge pull request #12 from fedorov-xyz/feat/operation-id
feat: Support operationId property
2 parents 9e775bc + f68a0b1 commit 30b5b6a

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dist/
22
types/
3-
coverage/
3+
coverage/

src/spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export function buildSpec(
183183
)
184184

185185
// Get OpenAPI supported tags
186-
const { summary, description, tags, security } = config.openapi ?? {}
186+
const { summary, description, tags, operationId, security } = config.openapi ?? {}
187187

188188
// Add the new operation
189189
for (const method of methods) {
@@ -192,6 +192,7 @@ export function buildSpec(
192192
spec.paths[path][method.toLowerCase()] = {
193193
summary,
194194
description,
195+
operationId,
195196
tags,
196197
security,
197198
parameters: parseParameters(instance, schema),

test/spec.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ test('Spec generation', async () => {
9393
openapi: {
9494
description: 'Makes a request',
9595
summary: 'Main route',
96-
tags: ['service']
96+
tags: ['service'],
97+
operationId: 'create-request'
9798
}
9899
},
99100
handler(_: FastifyRequest, reply: FastifyReply): void {
@@ -159,6 +160,7 @@ paths:
159160
post:
160161
summary: Main route
161162
description: Makes a request
163+
operationId: create-request
162164
tags:
163165
- service
164166
parameters:
@@ -256,6 +258,7 @@ paths:
256258
summary: 'Main route',
257259
description: 'Makes a request',
258260
tags: ['service'],
261+
operationId: 'create-request',
259262
parameters: [
260263
{
261264
name: 'why',

0 commit comments

Comments
 (0)