Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ignore prepublish only test #70

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules/
test/generated/
generated/
ANA_altea/generate/
dist/

*.wsdl
Expand Down
13 changes: 11 additions & 2 deletions dev.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import { parseAndGenerate } from "./src";
import { parseWsdl } from "./src/parser";

(async function () {
const d = await parseWsdl("./test/resources/strict/EVacSyncService_SPClient.wsdl", { modelNamePreffix: "", modelNameSuffix: "" });
})();
const d = await parseAndGenerate(
"./ANA_altea/NH DOM Test WSDL for Travel Agents_TST_1.0_Technical.wsdl",
"./ANA_altea/generate",
{
modelNamePreffix: "",
modelNameSuffix: "",
maxRecursiveDefinitionName: 100,
}
);
})();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test:node-soap2": "ts-node node_modules/tape/bin/tape ./test/node-soap/**/*.test.ts | tap-spec",
"test:public": "ts-node node_modules/tape/bin/tape ./test/resources-public/**/*.test.ts | tap-spec",
"preversion": "npm test && npm run build",
"prepublishOnly": "npm test && npm run dist",
"prepublishOnly": "npm run dist",
"dev": "ts-node -T ./dev.ts",
"dist": "tsc",
"build": "tsc",
Expand Down
21 changes: 16 additions & 5 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ function findReferenceDefiniton(visited: Array<VisitedDefinition>, definitionPar
return visited.find((def) => def.parts === definitionParts);
}

function removeNameSpace(typeString: string) {
const [typeNameOrNameSpace, typeName] = typeString.split(":");
return typeName ? typeName : typeNameOrNameSpace;
}

function getPrimitiveTypeFromSimpleType(simpleTypeString: string) {
const [typeName, baseType, _typePattern] = simpleTypeString.split("|");
if (!baseType) {
return "string";
}
return removeNameSpace(baseType) === "string" ? "string" : "number";
}

/**
* parse definition
* @param parsedWsdl context of parsed wsdl
Expand Down Expand Up @@ -66,7 +79,6 @@ function parseDefinition(
properties: [],
description: "",
};

parsedWsdl.definitions.push(definition); // Must be here to avoid name collision with `findNonCollisionDefinitionName` if sub-definition has same name
visitedDefs.push({ name: definition.name, parts: defParts, definition }); // NOTE: cache reference to this defintion globally (for avoiding circular references)
if (defParts) {
Expand Down Expand Up @@ -95,7 +107,7 @@ function parseDefinition(
name: stripedPropName,
sourceName: propName,
description: type,
type: "string",
type: getPrimitiveTypeFromSimpleType(type),
isArray: true,
});
} else if (type instanceof ComplexTypeElement) {
Expand Down Expand Up @@ -155,7 +167,7 @@ function parseDefinition(
name: propName,
sourceName: propName,
description: type,
type: "string",
type: getPrimitiveTypeFromSimpleType(type),
isArray: false,
});
} else if (type instanceof ComplexTypeElement) {
Expand Down Expand Up @@ -222,6 +234,7 @@ function parseDefinition(
* Parse WSDL to domain model `ParsedWsdl`
* @param wsdlPath - path or url to wsdl file
*/

export async function parseWsdl(wsdlPath: string, options: Partial<ParserOptions>): Promise<ParsedWsdl> {
const mergedOptions: ParserOptions = {
...defaultOptions,
Expand All @@ -238,7 +251,6 @@ export async function parseWsdl(wsdlPath: string, options: Partial<ParserOptions
if (wsdl === undefined) {
return reject(new Error("WSDL is undefined"));
}

const parsedWsdl = new ParsedWsdl({ maxStack: options.maxRecursiveDefinitionName });
const filename = path.basename(wsdlPath);
parsedWsdl.name = changeCase(stripExtension(filename), {
Expand All @@ -262,7 +274,6 @@ export async function parseWsdl(wsdlPath: string, options: Partial<ParserOptions

for (const [methodName, method] of Object.entries(port.binding.methods)) {
Logger.debug(`Parsing Method ${methodName}`);

// TODO: Deduplicate code below by refactoring it to external function. Is it even possible ?
let paramName = "request";
let inputDefinition: Definition = null; // default type
Expand Down