UNPKG

openapi-codegen-typescript

Version:

OpenApi codegen for generating types an mocks from swagger json file

94 lines (93 loc) 2.96 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var getResultStringType_1 = require("./getResultStringType"); var defaultProps = { type: 'invalid', items: undefined, oneOf: undefined, xDictionaryKey: undefined, additionalProperties: undefined, $ref: undefined, }; var scenarios = [ { input: __assign(__assign({}, defaultProps), { type: 'string' }), output: "String", }, { input: __assign(__assign({}, defaultProps), { type: 'integer' }), output: "Number", }, { input: __assign(__assign({}, defaultProps), { type: 'number' }), output: "Number", }, { input: __assign(__assign({}, defaultProps), { type: 'boolean' }), output: "Boolean", }, { input: __assign(__assign({}, defaultProps), { type: 'array', items: { $ref: '$ref mocked', } }), output: "ItemWithRef", }, { input: __assign(__assign({}, defaultProps), { type: 'array', items: [] }), output: "ItemWithoutRef", }, { input: __assign(__assign({}, defaultProps), { oneOf: [{ $ref: '$ref mocked' }] }), output: "OneOf", }, { input: __assign(__assign({}, defaultProps), { $ref: '$ref mocked' }), output: "Ref", }, { input: __assign(__assign({}, defaultProps), { type: undefined, $ref: undefined, oneOf: undefined }), output: "UndefinedTypeRefAndOneOf", }, { input: __assign(__assign({}, defaultProps), { xDictionaryKey: { $ref: '$ref mocked', }, additionalProperties: { $ref: '$ref mocked', } }), output: "DictionaryKey", }, { input: __assign(__assign({}, defaultProps), { xDictionaryKey: { $ref: '$ref mocked', }, additionalProperties: { type: 'type mocked', } }), output: "AdditionalPropertiesType", }, { input: __assign(__assign({}, defaultProps), { xDictionaryKey: undefined, additionalProperties: { type: 'type mocked', } }), output: "AdditionalPropertiesType", }, { input: __assign(__assign({}, defaultProps), { type: 'unsupported type' }), output: "Invalid", }, ]; it.each(scenarios)("should return expected string", function (_a) { var input = _a.input, output = _a.output; var result = getResultStringType_1.getResultStringType(input); expect(result).toBe(output); });