Skip to content

Commit f54af7d

Browse files
committed
feat(open-api): Automatically generate summary based on operationId
1 parent 4b011cd commit f54af7d

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

bun.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"dependencies": {
4949
"@standard-schema/spec": "^1.0.0",
5050
"openapi-types": "^12.1.3",
51-
"rou3": "^0.7.12"
51+
"rou3": "^0.7.12",
52+
"scule": "^1.3.0"
5253
},
5354
"devDependencies": {
5455
"@aklinker1/check": "^2.2.0",

src/internal/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { StandardSchemaV1 } from "@standard-schema/spec";
2+
import type { MatchedRoute } from "rou3";
23
import { HttpError } from "../errors";
4+
import type { ErrorResponse } from "../schema";
35
import { HttpStatus } from "../status";
6+
import { createBunTransport } from "../transports/bun-transport";
7+
import { createDenoTransport } from "../transports/deno-transport";
48
import type {
59
App,
610
LifeCycleHook,
@@ -9,10 +13,6 @@ import type {
913
StatusResult,
1014
Transport,
1115
} from "../types";
12-
import type { MatchedRoute } from "rou3";
13-
import type { ErrorResponse } from "../schema";
14-
import { createBunTransport } from "../transports/bun-transport";
15-
import { createDenoTransport } from "../transports/deno-transport";
1616

1717
export function validateSchema<T>(
1818
schema: StandardSchemaV1<T, T>,

src/open-api.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { StandardSchemaV1 } from "@standard-schema/spec";
22
import type { OpenAPI } from "openapi-types";
3+
import { titleCase } from "scule";
34
import type { CreateAppOptions } from "./app";
45
import { getMeta } from "./meta";
56
import {
@@ -54,6 +55,11 @@ export function buildOpenApiDocs(
5455

5556
(docs.paths[openApiPath] as any)[method.toLowerCase()] = {
5657
...openApiOperation,
58+
summary:
59+
openApiOperation.summary ??
60+
(openApiOperation.operationId
61+
? titleCase(openApiOperation.operationId)
62+
: undefined),
5763
requestBody: body
5864
? {
5965
content: {

0 commit comments

Comments
 (0)