sofa-api 0.6.1 → 0.7.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.
- package/index.cjs.js +8 -3
- package/index.esm.js +8 -3
- package/open-api/index.d.ts +3 -1
- package/package.json +2 -2
package/index.cjs.js
CHANGED
|
@@ -986,7 +986,7 @@ function isObjectTypeDefinitionNode(node) {
|
|
|
986
986
|
return node.kind === graphql.Kind.OBJECT_TYPE_DEFINITION;
|
|
987
987
|
}
|
|
988
988
|
|
|
989
|
-
function OpenAPI({ schema, info, }) {
|
|
989
|
+
function OpenAPI({ schema, info, components, security, }) {
|
|
990
990
|
const types = schema.getTypeMap();
|
|
991
991
|
const swagger = {
|
|
992
992
|
openapi: '3.0.0',
|
|
@@ -1003,10 +1003,15 @@ function OpenAPI({ schema, info, }) {
|
|
|
1003
1003
|
swagger.components.schemas[typeName] = buildSchemaObjectFromType(type);
|
|
1004
1004
|
}
|
|
1005
1005
|
}
|
|
1006
|
+
if (components) {
|
|
1007
|
+
swagger.components = Object.assign(Object.assign({}, components), swagger.components);
|
|
1008
|
+
}
|
|
1009
|
+
if (security) {
|
|
1010
|
+
swagger.security = security;
|
|
1011
|
+
}
|
|
1006
1012
|
return {
|
|
1007
1013
|
addRoute(info, config) {
|
|
1008
|
-
|
|
1009
|
-
const basePath = ((_a = config) === null || _a === void 0 ? void 0 : _a.basePath) || '';
|
|
1014
|
+
const basePath = (config === null || config === void 0 ? void 0 : config.basePath) || '';
|
|
1010
1015
|
const path = basePath +
|
|
1011
1016
|
info.path.replace(/\:[a-z0-9]+\w/i, param => `{${param.replace(':', '')}}`);
|
|
1012
1017
|
if (!swagger.paths[path]) {
|
package/index.esm.js
CHANGED
|
@@ -980,7 +980,7 @@ function isObjectTypeDefinitionNode(node) {
|
|
|
980
980
|
return node.kind === Kind.OBJECT_TYPE_DEFINITION;
|
|
981
981
|
}
|
|
982
982
|
|
|
983
|
-
function OpenAPI({ schema, info, }) {
|
|
983
|
+
function OpenAPI({ schema, info, components, security, }) {
|
|
984
984
|
const types = schema.getTypeMap();
|
|
985
985
|
const swagger = {
|
|
986
986
|
openapi: '3.0.0',
|
|
@@ -997,10 +997,15 @@ function OpenAPI({ schema, info, }) {
|
|
|
997
997
|
swagger.components.schemas[typeName] = buildSchemaObjectFromType(type);
|
|
998
998
|
}
|
|
999
999
|
}
|
|
1000
|
+
if (components) {
|
|
1001
|
+
swagger.components = Object.assign(Object.assign({}, components), swagger.components);
|
|
1002
|
+
}
|
|
1003
|
+
if (security) {
|
|
1004
|
+
swagger.security = security;
|
|
1005
|
+
}
|
|
1000
1006
|
return {
|
|
1001
1007
|
addRoute(info, config) {
|
|
1002
|
-
|
|
1003
|
-
const basePath = ((_a = config) === null || _a === void 0 ? void 0 : _a.basePath) || '';
|
|
1008
|
+
const basePath = (config === null || config === void 0 ? void 0 : config.basePath) || '';
|
|
1004
1009
|
const path = basePath +
|
|
1005
1010
|
info.path.replace(/\:[a-z0-9]+\w/i, param => `{${param.replace(':', '')}}`);
|
|
1006
1011
|
if (!swagger.paths[path]) {
|
package/open-api/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
2
|
import { RouteInfo } from '../types';
|
|
3
|
-
export declare function OpenAPI({ schema, info, }: {
|
|
3
|
+
export declare function OpenAPI({ schema, info, components, security, }: {
|
|
4
4
|
schema: GraphQLSchema;
|
|
5
5
|
info: Record<string, any>;
|
|
6
|
+
components?: Record<string, any>;
|
|
7
|
+
security?: Record<string, any>[];
|
|
6
8
|
}): {
|
|
7
9
|
addRoute(info: RouteInfo, config?: {
|
|
8
10
|
basePath?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sofa-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Create REST APIs with GraphQL",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"express": "^4.0.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"graphql-subscriptions": "1.1.0",
|
|
35
35
|
"iterall": "1.3.0",
|
|
36
36
|
"title-case": "3.0.2",
|
|
37
|
-
"tslib": "1.
|
|
37
|
+
"tslib": "1.11.1",
|
|
38
38
|
"uuid": "3.4.0",
|
|
39
39
|
"winston": "3.2.1",
|
|
40
40
|
"yamljs": "0.3.0"
|