Skip to content

Commit f5927ab

Browse files
committed
Add test to check HTTP method
Signed-off-by: Alan Cha <[email protected]>
1 parent 6bd7258 commit f5927ab

20 files changed

+10434
-1812
lines changed

packages/openapi-to-graphql-cli/package-lock.json

+10,179-1,716
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/oas_3_tools.d.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,20 @@ export declare type ResponseSchemaAndNames = {
2828
responseSchemaNames?: SchemaNames;
2929
statusCode?: string;
3030
};
31-
export declare const OAS_OPERATIONS: string[];
31+
export declare enum HTTP_METHODS {
32+
'get' = "get",
33+
'put' = "put",
34+
'post' = "post",
35+
'patch' = "patch",
36+
'delete' = "delete",
37+
'options' = "options",
38+
'head' = "head"
39+
}
3240
export declare const SUCCESS_STATUS_RX: RegExp;
41+
/**
42+
* Given an HTTP method, convert it to the HTTP_METHODS enum
43+
*/
44+
export declare function methodToHttpMethod(method: string): HTTP_METHODS;
3345
/**
3446
* Resolves on a validated OAS 3 for the given spec (OAS 2 or OAS 3), or rejects
3547
* if errors occur.
@@ -172,7 +184,7 @@ export declare function trim(str: string, length: number): string;
172184
* Determines if the given "method" is indeed an operation. Alternatively, the
173185
* method could point to other types of information (e.g., parameters, servers).
174186
*/
175-
export declare function isOperation(method: string): boolean;
187+
export declare function isHttpMethod(method: string): boolean;
176188
/**
177189
* Formats a string that describes an operation in the form:
178190
* {name of OAS} {HTTP method in ALL_CAPS} {operation path}

packages/openapi-to-graphql/lib/oas_3_tools.js

+44-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/oas_3_tools.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/preprocessor.js

+31-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/preprocessor.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/resolver_builder.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/resolver_builder.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/schema_builder.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/schema_builder.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/openapi-to-graphql/lib/types/operation.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import { Oas3, LinkObject, ParameterObject, ServerObject, SchemaObject } from './oas3';
66
import { GraphQLOperationType } from './graphql';
77
import { GraphQLScalarType, GraphQLObjectType, GraphQLInputObjectType, GraphQLList, GraphQLEnumType, GraphQLUnionType } from 'graphql';
8+
import { HTTP_METHODS } from '../oas_3_tools';
89
import * as GraphQLJSON from 'graphql-type-json';
910
export declare type DataDefinition = {
1011
preferredName: string;
@@ -65,7 +66,7 @@ export declare type Operation = {
6566
/**
6667
* HTTP method for this operation
6768
*/
68-
method: string;
69+
method: HTTP_METHODS;
6970
/**
7071
* Content-type of the request payload
7172
*/

0 commit comments

Comments
 (0)