Skip to content

Commit e549b80

Browse files
KrivtsovKrivtsov
authored andcommitted
New 1.0.3: passing through endpoint descriptions, skip odd chars in names
1 parent 46fa353 commit e549b80

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function getQueriesFields(endpoints, isMutation) {
6363
const type = createGQLObject(endpoint.response, typeName, endpoint.location);
6464
result[typeName] = {
6565
type,
66-
description: typeName,
66+
description: endpoint.description,
6767
args: mapParametersToFields(endpoint.parameters, endpoint.location, typeName),
6868
resolve: resolver(endpoint)
6969
};

lib/swagger.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ function loadSchema(pathToSchema) {
3232
return schema;
3333
}
3434

35+
function replaceOddChars(str) {
36+
return str.replace(/[^_a-zA-Z0-9]/g, '_');
37+
}
38+
3539
/**
3640
* Going throw schema and grab routes
3741
* @returns Promise<T>
@@ -46,10 +50,11 @@ function getAllEndPoints(schema) {
4650
const typeName = getGQLTypeNameFromURL(method, path);
4751
const parameters = obj.parameters ? obj.parameters.map(param => {
4852
const type = param.type;
49-
return {name: param.name, type, jsonSchema: param};
53+
return {name: replaceOddChars(param.name), type, jsonSchema: param};
5054
}) : [];
5155
allTypes[typeName] = {
5256
parameters,
57+
description: obj.description,
5358
response: getSuccessResponse(obj.responses),
5459
request: (args, server) => {
5560
const url = `${server.baseUrl}${path}`;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "swagger-to-graphql",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "",
55
"main": "lib/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)