-
Notifications
You must be signed in to change notification settings - Fork 317
Expand file tree
/
Copy pathconvertToHttpMethod.ts
More file actions
23 lines (22 loc) · 1.07 KB
/
convertToHttpMethod.ts
File metadata and controls
23 lines (22 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { RawSchemas } from "@fern-api/fern-definition-schema";
import { HttpMethod } from "@fern-api/openapi-ir";
import { CliError } from "@fern-api/task-context";
export function convertToHttpMethod(httpMethod: HttpMethod): RawSchemas.HttpMethodSchema {
return HttpMethod._visit<RawSchemas.HttpMethodSchema>(httpMethod, {
get: () => RawSchemas.HttpMethodSchema.Get,
post: () => RawSchemas.HttpMethodSchema.Post,
put: () => RawSchemas.HttpMethodSchema.Put,
patch: () => RawSchemas.HttpMethodSchema.Patch,
delete: () => RawSchemas.HttpMethodSchema.Delete,
head: () => RawSchemas.HttpMethodSchema.Head,
options: () => {
throw new CliError({ message: "OPTIONS is unsupported", code: CliError.Code.ConfigError });
},
trace: () => {
throw new CliError({ message: "TRACE is unsupported", code: CliError.Code.ConfigError });
},
_other: () => {
throw new CliError({ message: "Unknown http method is unsupported", code: CliError.Code.ConfigError });
}
});
}