diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000000..def43c73b659 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +**/*.mustache linguist-vendored=true diff --git a/.github/.test/auto-labeler.js b/.github/.test/auto-labeler.js new file mode 100644 index 000000000000..d8cf3ede4202 --- /dev/null +++ b/.github/.test/auto-labeler.js @@ -0,0 +1,117 @@ +let fs = require('fs'); +let path = require('path'); +let util = require('util'); +let yaml = require('./js-yaml.js'); +let samples = require('./samples.json'); + +class LabelMatch { + constructor (match, label) { + this.match = match; + this.label = label; + } +} + +class FileError { + constructor (file, actualLabels, expectedLabels) { + this.file = file; + this.actual = actualLabels; + this.expected = expectedLabels; + } +} + +class TextError { + constructor (text, actualLabels, expectedLabels) { + this.text = text; + this.actual = actualLabels; + this.expected = expectedLabels; + } +} + +let labels = []; + +function labelsForFile(file) { + let body = fs.readFileSync(file); + return labelsForText(body) +} + +function labelsForText(text) { + let addLabels = new Set(); + let body = text; + for (const v of labels) { + if (v.match.test(body)) { + addLabels.add(v.label) + } + // reset regex state + v.match.lastIndex = 0 + } + return addLabels; +} + +try { + let config = yaml.safeLoad(fs.readFileSync('../auto-labeler.yml', 'utf8')); + + if (config && config.labels && Object.keys(config.labels).length > 0) { + for (const labelName in config.labels) { + if (config.labels.hasOwnProperty(labelName)) { + let matchAgainst = config.labels[labelName]; + if (Array.isArray(matchAgainst)) { + matchAgainst.forEach(regex => { + // noinspection JSCheckFunctionSignatures + labels.push(new LabelMatch(new RegExp(regex, 'g'), labelName)); + }) + } + } + } + } + + if (labels.length === 0) { + // noinspection ExceptionCaughtLocallyJS + throw new Error("Expected to parse config.labels, but failed.") + } + + let fileErrors = []; + samples.files.forEach(function(tester){ + let file = path.normalize(path.join('..', '..', 'bin', tester.input)); + let expectedLabels = new Set(tester.matches); + let actualLabels = labelsForFile(file); + let difference = new Set([...actualLabels].filter(x => !expectedLabels.has(x))); + if (difference.size > 0) { + fileErrors.push(new FileError(file, actualLabels, expectedLabels)); + } + }); + + let textErrors = []; + samples.text.forEach(function(tester){ + let expectedLabels = new Set(tester.matches); + let actualLabels = labelsForText(tester.input); + let difference = new Set([...actualLabels].filter(x => !expectedLabels.has(x))); + if (difference.size > 0) { + textErrors.push(new TextError(tester.input, actualLabels, expectedLabels)); + } + }); + + // These are separate (file vs text) in case we want to preview where these would fail in the file. not priority at the moment. + if (fileErrors.length > 0) { + console.warn('There were %d file tester errors', fileErrors.length); + fileErrors.forEach(function(errs) { + console.log("file: %j\n actual: %j\n expected: %j", errs.file, util.inspect(errs.actual), util.inspect(errs.expected)) + }); + } + + if (textErrors.length > 0) { + console.warn('There were %d text tester errors', textErrors.length); + textErrors.forEach(function(errs){ + console.log("input: %j\n actual: %j\n expected: %j", errs.text, util.inspect(errs.actual), util.inspect(errs.expected)) + }) + } + + let totalErrors = fileErrors.length + textErrors.length; + if (totalErrors === 0) { + console.log('Success!'); + } else { + console.log('Failure: %d total errors', totalErrors); + } +} catch (e) { + console.log(e); +} + diff --git a/.github/.test/js-yaml.js b/.github/.test/js-yaml.js new file mode 100644 index 000000000000..0c9e648bd07c --- /dev/null +++ b/.github/.test/js-yaml.js @@ -0,0 +1,3917 @@ +/* js-yaml 3.12.0 https://github.com/nodeca/js-yaml */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jsyaml = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i */ +var CHAR_QUESTION = 0x3F; /* ? */ +var CHAR_COMMERCIAL_AT = 0x40; /* @ */ +var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ +var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ +var CHAR_GRAVE_ACCENT = 0x60; /* ` */ +var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ +var CHAR_VERTICAL_LINE = 0x7C; /* | */ +var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ + +var ESCAPE_SEQUENCES = {}; + +ESCAPE_SEQUENCES[0x00] = '\\0'; +ESCAPE_SEQUENCES[0x07] = '\\a'; +ESCAPE_SEQUENCES[0x08] = '\\b'; +ESCAPE_SEQUENCES[0x09] = '\\t'; +ESCAPE_SEQUENCES[0x0A] = '\\n'; +ESCAPE_SEQUENCES[0x0B] = '\\v'; +ESCAPE_SEQUENCES[0x0C] = '\\f'; +ESCAPE_SEQUENCES[0x0D] = '\\r'; +ESCAPE_SEQUENCES[0x1B] = '\\e'; +ESCAPE_SEQUENCES[0x22] = '\\"'; +ESCAPE_SEQUENCES[0x5C] = '\\\\'; +ESCAPE_SEQUENCES[0x85] = '\\N'; +ESCAPE_SEQUENCES[0xA0] = '\\_'; +ESCAPE_SEQUENCES[0x2028] = '\\L'; +ESCAPE_SEQUENCES[0x2029] = '\\P'; + +var DEPRECATED_BOOLEANS_SYNTAX = [ + 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', + 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' +]; + +function compileStyleMap(schema, map) { + var result, keys, index, length, tag, style, type; + + if (map === null) return {}; + + result = {}; + keys = Object.keys(map); + + for (index = 0, length = keys.length; index < length; index += 1) { + tag = keys[index]; + style = String(map[tag]); + + if (tag.slice(0, 2) === '!!') { + tag = 'tag:yaml.org,2002:' + tag.slice(2); + } + type = schema.compiledTypeMap['fallback'][tag]; + + if (type && _hasOwnProperty.call(type.styleAliases, style)) { + style = type.styleAliases[style]; + } + + result[tag] = style; + } + + return result; +} + +function encodeHex(character) { + var string, handle, length; + + string = character.toString(16).toUpperCase(); + + if (character <= 0xFF) { + handle = 'x'; + length = 2; + } else if (character <= 0xFFFF) { + handle = 'u'; + length = 4; + } else if (character <= 0xFFFFFFFF) { + handle = 'U'; + length = 8; + } else { + throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF'); + } + + return '\\' + handle + common.repeat('0', length - string.length) + string; +} + +function State(options) { + this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; + this.indent = Math.max(1, (options['indent'] || 2)); + this.skipInvalid = options['skipInvalid'] || false; + this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); + this.styleMap = compileStyleMap(this.schema, options['styles'] || null); + this.sortKeys = options['sortKeys'] || false; + this.lineWidth = options['lineWidth'] || 80; + this.noRefs = options['noRefs'] || false; + this.noCompatMode = options['noCompatMode'] || false; + this.condenseFlow = options['condenseFlow'] || false; + + this.implicitTypes = this.schema.compiledImplicit; + this.explicitTypes = this.schema.compiledExplicit; + + this.tag = null; + this.result = ''; + + this.duplicates = []; + this.usedDuplicates = null; +} + +// Indents every line in a string. Empty lines (\n only) are not indented. +function indentString(string, spaces) { + var ind = common.repeat(' ', spaces), + position = 0, + next = -1, + result = '', + line, + length = string.length; + + while (position < length) { + next = string.indexOf('\n', position); + if (next === -1) { + line = string.slice(position); + position = length; + } else { + line = string.slice(position, next + 1); + position = next + 1; + } + + if (line.length && line !== '\n') result += ind; + + result += line; + } + + return result; +} + +function generateNextLine(state, level) { + return '\n' + common.repeat(' ', state.indent * level); +} + +function testImplicitResolving(state, str) { + var index, length, type; + + for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { + type = state.implicitTypes[index]; + + if (type.resolve(str)) { + return true; + } + } + + return false; +} + +// [33] s-white ::= s-space | s-tab +function isWhitespace(c) { + return c === CHAR_SPACE || c === CHAR_TAB; +} + +// Returns true if the character can be printed without escaping. +// From YAML 1.2: "any allowed characters known to be non-printable +// should also be escaped. [However,] This isn’t mandatory" +// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. +function isPrintable(c) { + return (0x00020 <= c && c <= 0x00007E) + || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) + || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */) + || (0x10000 <= c && c <= 0x10FFFF); +} + +// Simplified test for values allowed after the first character in plain style. +function isPlainSafe(c) { + // Uses a subset of nb-char - c-flow-indicator - ":" - "#" + // where nb-char ::= c-printable - b-char - c-byte-order-mark. + return isPrintable(c) && c !== 0xFEFF + // - c-flow-indicator + && c !== CHAR_COMMA + && c !== CHAR_LEFT_SQUARE_BRACKET + && c !== CHAR_RIGHT_SQUARE_BRACKET + && c !== CHAR_LEFT_CURLY_BRACKET + && c !== CHAR_RIGHT_CURLY_BRACKET + // - ":" - "#" + && c !== CHAR_COLON + && c !== CHAR_SHARP; +} + +// Simplified test for values allowed as the first character in plain style. +function isPlainSafeFirst(c) { + // Uses a subset of ns-char - c-indicator + // where ns-char = nb-char - s-white. + return isPrintable(c) && c !== 0xFEFF + && !isWhitespace(c) // - s-white + // - (c-indicator ::= + // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” + && c !== CHAR_MINUS + && c !== CHAR_QUESTION + && c !== CHAR_COLON + && c !== CHAR_COMMA + && c !== CHAR_LEFT_SQUARE_BRACKET + && c !== CHAR_RIGHT_SQUARE_BRACKET + && c !== CHAR_LEFT_CURLY_BRACKET + && c !== CHAR_RIGHT_CURLY_BRACKET + // | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"” + && c !== CHAR_SHARP + && c !== CHAR_AMPERSAND + && c !== CHAR_ASTERISK + && c !== CHAR_EXCLAMATION + && c !== CHAR_VERTICAL_LINE + && c !== CHAR_GREATER_THAN + && c !== CHAR_SINGLE_QUOTE + && c !== CHAR_DOUBLE_QUOTE + // | “%” | “@” | “`”) + && c !== CHAR_PERCENT + && c !== CHAR_COMMERCIAL_AT + && c !== CHAR_GRAVE_ACCENT; +} + +// Determines whether block indentation indicator is required. +function needIndentIndicator(string) { + var leadingSpaceRe = /^\n* /; + return leadingSpaceRe.test(string); +} + +var STYLE_PLAIN = 1, + STYLE_SINGLE = 2, + STYLE_LITERAL = 3, + STYLE_FOLDED = 4, + STYLE_DOUBLE = 5; + +// Determines which scalar styles are possible and returns the preferred style. +// lineWidth = -1 => no limit. +// Pre-conditions: str.length > 0. +// Post-conditions: +// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. +// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). +// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). +function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) { + var i; + var char; + var hasLineBreak = false; + var hasFoldableLine = false; // only checked if shouldTrackWidth + var shouldTrackWidth = lineWidth !== -1; + var previousLineBreak = -1; // count the first line correctly + var plain = isPlainSafeFirst(string.charCodeAt(0)) + && !isWhitespace(string.charCodeAt(string.length - 1)); + + if (singleLineOnly) { + // Case: no block styles. + // Check for disallowed characters to rule out plain and single. + for (i = 0; i < string.length; i++) { + char = string.charCodeAt(i); + if (!isPrintable(char)) { + return STYLE_DOUBLE; + } + plain = plain && isPlainSafe(char); + } + } else { + // Case: block styles permitted. + for (i = 0; i < string.length; i++) { + char = string.charCodeAt(i); + if (char === CHAR_LINE_FEED) { + hasLineBreak = true; + // Check if any line can be folded. + if (shouldTrackWidth) { + hasFoldableLine = hasFoldableLine || + // Foldable line = too long, and not more-indented. + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' '); + previousLineBreak = i; + } + } else if (!isPrintable(char)) { + return STYLE_DOUBLE; + } + plain = plain && isPlainSafe(char); + } + // in case the end is missing a \n + hasFoldableLine = hasFoldableLine || (shouldTrackWidth && + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' ')); + } + // Although every style can represent \n without escaping, prefer block styles + // for multiline, since they're more readable and they don't add empty lines. + // Also prefer folding a super-long line. + if (!hasLineBreak && !hasFoldableLine) { + // Strings interpretable as another type have to be quoted; + // e.g. the string 'true' vs. the boolean true. + return plain && !testAmbiguousType(string) + ? STYLE_PLAIN : STYLE_SINGLE; + } + // Edge case: block indentation indicator can only have one digit. + if (indentPerLevel > 9 && needIndentIndicator(string)) { + return STYLE_DOUBLE; + } + // At this point we know block styles are valid. + // Prefer literal style unless we want to fold. + return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; +} + +// Note: line breaking/folding is implemented for only the folded style. +// NB. We drop the last trailing newline (if any) of a returned block scalar +// since the dumper adds its own newline. This always works: +// • No ending newline => unaffected; already using strip "-" chomping. +// • Ending newline => removed then restored. +// Importantly, this keeps the "+" chomp indicator from gaining an extra line. +function writeScalar(state, string, level, iskey) { + state.dump = (function () { + if (string.length === 0) { + return "''"; + } + if (!state.noCompatMode && + DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) { + return "'" + string + "'"; + } + + var indent = state.indent * Math.max(1, level); // no 0-indent scalars + // As indentation gets deeper, let the width decrease monotonically + // to the lower bound min(state.lineWidth, 40). + // Note that this implies + // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. + // state.lineWidth > 40 + state.indent: width decreases until the lower bound. + // This behaves better than a constant minimum width which disallows narrower options, + // or an indent threshold which causes the width to suddenly increase. + var lineWidth = state.lineWidth === -1 + ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); + + // Without knowing if keys are implicit/explicit, assume implicit for safety. + var singleLineOnly = iskey + // No block styles in flow mode. + || (state.flowLevel > -1 && level >= state.flowLevel); + function testAmbiguity(string) { + return testImplicitResolving(state, string); + } + + switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) { + case STYLE_PLAIN: + return string; + case STYLE_SINGLE: + return "'" + string.replace(/'/g, "''") + "'"; + case STYLE_LITERAL: + return '|' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(string, indent)); + case STYLE_FOLDED: + return '>' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); + case STYLE_DOUBLE: + return '"' + escapeString(string, lineWidth) + '"'; + default: + throw new YAMLException('impossible error: invalid scalar style'); + } + }()); +} + +// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. +function blockHeader(string, indentPerLevel) { + var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; + + // note the special case: the string '\n' counts as a "trailing" empty line. + var clip = string[string.length - 1] === '\n'; + var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); + var chomp = keep ? '+' : (clip ? '' : '-'); + + return indentIndicator + chomp + '\n'; +} + +// (See the note for writeScalar.) +function dropEndingNewline(string) { + return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; +} + +// Note: a long line without a suitable break point will exceed the width limit. +// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. +function foldString(string, width) { + // In folded style, $k$ consecutive newlines output as $k+1$ newlines— + // unless they're before or after a more-indented line, or at the very + // beginning or end, in which case $k$ maps to $k$. + // Therefore, parse each chunk as newline(s) followed by a content line. + var lineRe = /(\n+)([^\n]*)/g; + + // first line (possibly an empty line) + var result = (function () { + var nextLF = string.indexOf('\n'); + nextLF = nextLF !== -1 ? nextLF : string.length; + lineRe.lastIndex = nextLF; + return foldLine(string.slice(0, nextLF), width); + }()); + // If we haven't reached the first content line yet, don't add an extra \n. + var prevMoreIndented = string[0] === '\n' || string[0] === ' '; + var moreIndented; + + // rest of the lines + var match; + while ((match = lineRe.exec(string))) { + var prefix = match[1], line = match[2]; + moreIndented = (line[0] === ' '); + result += prefix + + (!prevMoreIndented && !moreIndented && line !== '' + ? '\n' : '') + + foldLine(line, width); + prevMoreIndented = moreIndented; + } + + return result; +} + +// Greedy line breaking. +// Picks the longest line under the limit each time, +// otherwise settles for the shortest line over the limit. +// NB. More-indented lines *cannot* be folded, as that would add an extra \n. +function foldLine(line, width) { + if (line === '' || line[0] === ' ') return line; + + // Since a more-indented line adds a \n, breaks can't be followed by a space. + var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. + var match; + // start is an inclusive index. end, curr, and next are exclusive. + var start = 0, end, curr = 0, next = 0; + var result = ''; + + // Invariants: 0 <= start <= length-1. + // 0 <= curr <= next <= max(0, length-2). curr - start <= width. + // Inside the loop: + // A match implies length >= 2, so curr and next are <= length-2. + while ((match = breakRe.exec(line))) { + next = match.index; + // maintain invariant: curr - start <= width + if (next - start > width) { + end = (curr > start) ? curr : next; // derive end <= length-2 + result += '\n' + line.slice(start, end); + // skip the space that was output as \n + start = end + 1; // derive start <= length-1 + } + curr = next; + } + + // By the invariants, start <= length-1, so there is something left over. + // It is either the whole string or a part starting from non-whitespace. + result += '\n'; + // Insert a break if the remainder is too long and there is a break available. + if (line.length - start > width && curr > start) { + result += line.slice(start, curr) + '\n' + line.slice(curr + 1); + } else { + result += line.slice(start); + } + + return result.slice(1); // drop extra \n joiner +} + +// Escapes a double-quoted string. +function escapeString(string) { + var result = ''; + var char, nextChar; + var escapeSeq; + + for (var i = 0; i < string.length; i++) { + char = string.charCodeAt(i); + // Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates"). + if (char >= 0xD800 && char <= 0xDBFF/* high surrogate */) { + nextChar = string.charCodeAt(i + 1); + if (nextChar >= 0xDC00 && nextChar <= 0xDFFF/* low surrogate */) { + // Combine the surrogate pair and store it escaped. + result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000); + // Advance index one extra since we already used that char here. + i++; continue; + } + } + escapeSeq = ESCAPE_SEQUENCES[char]; + result += !escapeSeq && isPrintable(char) + ? string[i] + : escapeSeq || encodeHex(char); + } + + return result; +} + +function writeFlowSequence(state, level, object) { + var _result = '', + _tag = state.tag, + index, + length; + + for (index = 0, length = object.length; index < length; index += 1) { + // Write only valid elements. + if (writeNode(state, level, object[index], false, false)) { + if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : ''); + _result += state.dump; + } + } + + state.tag = _tag; + state.dump = '[' + _result + ']'; +} + +function writeBlockSequence(state, level, object, compact) { + var _result = '', + _tag = state.tag, + index, + length; + + for (index = 0, length = object.length; index < length; index += 1) { + // Write only valid elements. + if (writeNode(state, level + 1, object[index], true, true)) { + if (!compact || index !== 0) { + _result += generateNextLine(state, level); + } + + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + _result += '-'; + } else { + _result += '- '; + } + + _result += state.dump; + } + } + + state.tag = _tag; + state.dump = _result || '[]'; // Empty sequence if no valid values. +} + +function writeFlowMapping(state, level, object) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + pairBuffer; + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + pairBuffer = state.condenseFlow ? '"' : ''; + + if (index !== 0) pairBuffer += ', '; + + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; + + if (!writeNode(state, level, objectKey, false, false)) { + continue; // Skip this pair because of invalid key; + } + + if (state.dump.length > 1024) pairBuffer += '? '; + + pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); + + if (!writeNode(state, level, objectValue, false, false)) { + continue; // Skip this pair because of invalid value. + } + + pairBuffer += state.dump; + + // Both key and value are valid. + _result += pairBuffer; + } + + state.tag = _tag; + state.dump = '{' + _result + '}'; +} + +function writeBlockMapping(state, level, object, compact) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + explicitPair, + pairBuffer; + + // Allow sorting keys so that the output file is deterministic + if (state.sortKeys === true) { + // Default sorting + objectKeyList.sort(); + } else if (typeof state.sortKeys === 'function') { + // Custom sort function + objectKeyList.sort(state.sortKeys); + } else if (state.sortKeys) { + // Something is wrong + throw new YAMLException('sortKeys must be a boolean or a function'); + } + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + pairBuffer = ''; + + if (!compact || index !== 0) { + pairBuffer += generateNextLine(state, level); + } + + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; + + if (!writeNode(state, level + 1, objectKey, true, true, true)) { + continue; // Skip this pair because of invalid key. + } + + explicitPair = (state.tag !== null && state.tag !== '?') || + (state.dump && state.dump.length > 1024); + + if (explicitPair) { + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += '?'; + } else { + pairBuffer += '? '; + } + } + + pairBuffer += state.dump; + + if (explicitPair) { + pairBuffer += generateNextLine(state, level); + } + + if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { + continue; // Skip this pair because of invalid value. + } + + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += ':'; + } else { + pairBuffer += ': '; + } + + pairBuffer += state.dump; + + // Both key and value are valid. + _result += pairBuffer; + } + + state.tag = _tag; + state.dump = _result || '{}'; // Empty mapping if no valid pairs. +} + +function detectType(state, object, explicit) { + var _result, typeList, index, length, type, style; + + typeList = explicit ? state.explicitTypes : state.implicitTypes; + + for (index = 0, length = typeList.length; index < length; index += 1) { + type = typeList[index]; + + if ((type.instanceOf || type.predicate) && + (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && + (!type.predicate || type.predicate(object))) { + + state.tag = explicit ? type.tag : '?'; + + if (type.represent) { + style = state.styleMap[type.tag] || type.defaultStyle; + + if (_toString.call(type.represent) === '[object Function]') { + _result = type.represent(object, style); + } else if (_hasOwnProperty.call(type.represent, style)) { + _result = type.represent[style](object, style); + } else { + throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); + } + + state.dump = _result; + } + + return true; + } + } + + return false; +} + +// Serializes `object` and writes it to global `result`. +// Returns true on success, or false on invalid object. +// +function writeNode(state, level, object, block, compact, iskey) { + state.tag = null; + state.dump = object; + + if (!detectType(state, object, false)) { + detectType(state, object, true); + } + + var type = _toString.call(state.dump); + + if (block) { + block = (state.flowLevel < 0 || state.flowLevel > level); + } + + var objectOrArray = type === '[object Object]' || type === '[object Array]', + duplicateIndex, + duplicate; + + if (objectOrArray) { + duplicateIndex = state.duplicates.indexOf(object); + duplicate = duplicateIndex !== -1; + } + + if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { + compact = false; + } + + if (duplicate && state.usedDuplicates[duplicateIndex]) { + state.dump = '*ref_' + duplicateIndex; + } else { + if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { + state.usedDuplicates[duplicateIndex] = true; + } + if (type === '[object Object]') { + if (block && (Object.keys(state.dump).length !== 0)) { + writeBlockMapping(state, level, state.dump, compact); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + state.dump; + } + } else { + writeFlowMapping(state, level, state.dump); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + } + } + } else if (type === '[object Array]') { + if (block && (state.dump.length !== 0)) { + writeBlockSequence(state, level, state.dump, compact); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + state.dump; + } + } else { + writeFlowSequence(state, level, state.dump); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + } + } + } else if (type === '[object String]') { + if (state.tag !== '?') { + writeScalar(state, state.dump, level, iskey); + } + } else { + if (state.skipInvalid) return false; + throw new YAMLException('unacceptable kind of an object to dump ' + type); + } + + if (state.tag !== null && state.tag !== '?') { + state.dump = '!<' + state.tag + '> ' + state.dump; + } + } + + return true; +} + +function getDuplicateReferences(object, state) { + var objects = [], + duplicatesIndexes = [], + index, + length; + + inspectNode(object, objects, duplicatesIndexes); + + for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { + state.duplicates.push(objects[duplicatesIndexes[index]]); + } + state.usedDuplicates = new Array(length); +} + +function inspectNode(object, objects, duplicatesIndexes) { + var objectKeyList, + index, + length; + + if (object !== null && typeof object === 'object') { + index = objects.indexOf(object); + if (index !== -1) { + if (duplicatesIndexes.indexOf(index) === -1) { + duplicatesIndexes.push(index); + } + } else { + objects.push(object); + + if (Array.isArray(object)) { + for (index = 0, length = object.length; index < length; index += 1) { + inspectNode(object[index], objects, duplicatesIndexes); + } + } else { + objectKeyList = Object.keys(object); + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); + } + } + } + } +} + +function dump(input, options) { + options = options || {}; + + var state = new State(options); + + if (!state.noRefs) getDuplicateReferences(input, state); + + if (writeNode(state, 0, input, true, true)) return state.dump + '\n'; + + return ''; +} + +function safeDump(input, options) { + return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); +} + +module.exports.dump = dump; +module.exports.safeDump = safeDump; + +},{"./common":2,"./exception":4,"./schema/default_full":9,"./schema/default_safe":10}],4:[function(require,module,exports){ +// YAML error class. http://stackoverflow.com/questions/8458984 +// +'use strict'; + +function YAMLException(reason, mark) { + // Super constructor + Error.call(this); + + this.name = 'YAMLException'; + this.reason = reason; + this.mark = mark; + this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : ''); + + // Include stack trace in error object + if (Error.captureStackTrace) { + // Chrome and NodeJS + Error.captureStackTrace(this, this.constructor); + } else { + // FF, IE 10+ and Safari 6+. Fallback for others + this.stack = (new Error()).stack || ''; + } +} + + +// Inherit from Error +YAMLException.prototype = Object.create(Error.prototype); +YAMLException.prototype.constructor = YAMLException; + + +YAMLException.prototype.toString = function toString(compact) { + var result = this.name + ': '; + + result += this.reason || '(unknown reason)'; + + if (!compact && this.mark) { + result += ' ' + this.mark.toString(); + } + + return result; +}; + + +module.exports = YAMLException; + +},{}],5:[function(require,module,exports){ +'use strict'; + +/*eslint-disable max-len,no-use-before-define*/ + +var common = require('./common'); +var YAMLException = require('./exception'); +var Mark = require('./mark'); +var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe'); +var DEFAULT_FULL_SCHEMA = require('./schema/default_full'); + + +var _hasOwnProperty = Object.prototype.hasOwnProperty; + + +var CONTEXT_FLOW_IN = 1; +var CONTEXT_FLOW_OUT = 2; +var CONTEXT_BLOCK_IN = 3; +var CONTEXT_BLOCK_OUT = 4; + + +var CHOMPING_CLIP = 1; +var CHOMPING_STRIP = 2; +var CHOMPING_KEEP = 3; + + +var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; +var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; +var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; +var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; +var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; + + +function is_EOL(c) { + return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); +} + +function is_WHITE_SPACE(c) { + return (c === 0x09/* Tab */) || (c === 0x20/* Space */); +} + +function is_WS_OR_EOL(c) { + return (c === 0x09/* Tab */) || + (c === 0x20/* Space */) || + (c === 0x0A/* LF */) || + (c === 0x0D/* CR */); +} + +function is_FLOW_INDICATOR(c) { + return c === 0x2C/* , */ || + c === 0x5B/* [ */ || + c === 0x5D/* ] */ || + c === 0x7B/* { */ || + c === 0x7D/* } */; +} + +function fromHexCode(c) { + var lc; + + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + /*eslint-disable no-bitwise*/ + lc = c | 0x20; + + if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { + return lc - 0x61 + 10; + } + + return -1; +} + +function escapedHexLen(c) { + if (c === 0x78/* x */) { return 2; } + if (c === 0x75/* u */) { return 4; } + if (c === 0x55/* U */) { return 8; } + return 0; +} + +function fromDecimalCode(c) { + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + return -1; +} + +function simpleEscapeSequence(c) { + /* eslint-disable indent */ + return (c === 0x30/* 0 */) ? '\x00' : + (c === 0x61/* a */) ? '\x07' : + (c === 0x62/* b */) ? '\x08' : + (c === 0x74/* t */) ? '\x09' : + (c === 0x09/* Tab */) ? '\x09' : + (c === 0x6E/* n */) ? '\x0A' : + (c === 0x76/* v */) ? '\x0B' : + (c === 0x66/* f */) ? '\x0C' : + (c === 0x72/* r */) ? '\x0D' : + (c === 0x65/* e */) ? '\x1B' : + (c === 0x20/* Space */) ? ' ' : + (c === 0x22/* " */) ? '\x22' : + (c === 0x2F/* / */) ? '/' : + (c === 0x5C/* \ */) ? '\x5C' : + (c === 0x4E/* N */) ? '\x85' : + (c === 0x5F/* _ */) ? '\xA0' : + (c === 0x4C/* L */) ? '\u2028' : + (c === 0x50/* P */) ? '\u2029' : ''; +} + +function charFromCodepoint(c) { + if (c <= 0xFFFF) { + return String.fromCharCode(c); + } + // Encode UTF-16 surrogate pair + // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF + return String.fromCharCode( + ((c - 0x010000) >> 10) + 0xD800, + ((c - 0x010000) & 0x03FF) + 0xDC00 + ); +} + +var simpleEscapeCheck = new Array(256); // integer, for fast access +var simpleEscapeMap = new Array(256); +for (var i = 0; i < 256; i++) { + simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; + simpleEscapeMap[i] = simpleEscapeSequence(i); +} + + +function State(input, options) { + this.input = input; + + this.filename = options['filename'] || null; + this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; + this.onWarning = options['onWarning'] || null; + this.legacy = options['legacy'] || false; + this.json = options['json'] || false; + this.listener = options['listener'] || null; + + this.implicitTypes = this.schema.compiledImplicit; + this.typeMap = this.schema.compiledTypeMap; + + this.length = input.length; + this.position = 0; + this.line = 0; + this.lineStart = 0; + this.lineIndent = 0; + + this.documents = []; + + /* + this.version; + this.checkLineBreaks; + this.tagMap; + this.anchorMap; + this.tag; + this.anchor; + this.kind; + this.result;*/ + +} + + +function generateError(state, message) { + return new YAMLException( + message, + new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart))); +} + +function throwError(state, message) { + throw generateError(state, message); +} + +function throwWarning(state, message) { + if (state.onWarning) { + state.onWarning.call(null, generateError(state, message)); + } +} + + +var directiveHandlers = { + + YAML: function handleYamlDirective(state, name, args) { + + var match, major, minor; + + if (state.version !== null) { + throwError(state, 'duplication of %YAML directive'); + } + + if (args.length !== 1) { + throwError(state, 'YAML directive accepts exactly one argument'); + } + + match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); + + if (match === null) { + throwError(state, 'ill-formed argument of the YAML directive'); + } + + major = parseInt(match[1], 10); + minor = parseInt(match[2], 10); + + if (major !== 1) { + throwError(state, 'unacceptable YAML version of the document'); + } + + state.version = args[0]; + state.checkLineBreaks = (minor < 2); + + if (minor !== 1 && minor !== 2) { + throwWarning(state, 'unsupported YAML version of the document'); + } + }, + + TAG: function handleTagDirective(state, name, args) { + + var handle, prefix; + + if (args.length !== 2) { + throwError(state, 'TAG directive accepts exactly two arguments'); + } + + handle = args[0]; + prefix = args[1]; + + if (!PATTERN_TAG_HANDLE.test(handle)) { + throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); + } + + if (_hasOwnProperty.call(state.tagMap, handle)) { + throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); + } + + if (!PATTERN_TAG_URI.test(prefix)) { + throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); + } + + state.tagMap[handle] = prefix; + } +}; + + +function captureSegment(state, start, end, checkJson) { + var _position, _length, _character, _result; + + if (start < end) { + _result = state.input.slice(start, end); + + if (checkJson) { + for (_position = 0, _length = _result.length; _position < _length; _position += 1) { + _character = _result.charCodeAt(_position); + if (!(_character === 0x09 || + (0x20 <= _character && _character <= 0x10FFFF))) { + throwError(state, 'expected valid JSON character'); + } + } + } else if (PATTERN_NON_PRINTABLE.test(_result)) { + throwError(state, 'the stream contains non-printable characters'); + } + + state.result += _result; + } +} + +function mergeMappings(state, destination, source, overridableKeys) { + var sourceKeys, key, index, quantity; + + if (!common.isObject(source)) { + throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); + } + + sourceKeys = Object.keys(source); + + for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { + key = sourceKeys[index]; + + if (!_hasOwnProperty.call(destination, key)) { + destination[key] = source[key]; + overridableKeys[key] = true; + } + } +} + +function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) { + var index, quantity; + + keyNode = String(keyNode); + + if (_result === null) { + _result = {}; + } + + if (keyTag === 'tag:yaml.org,2002:merge') { + if (Array.isArray(valueNode)) { + for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { + mergeMappings(state, _result, valueNode[index], overridableKeys); + } + } else { + mergeMappings(state, _result, valueNode, overridableKeys); + } + } else { + if (!state.json && + !_hasOwnProperty.call(overridableKeys, keyNode) && + _hasOwnProperty.call(_result, keyNode)) { + state.line = startLine || state.line; + state.position = startPos || state.position; + throwError(state, 'duplicated mapping key'); + } + _result[keyNode] = valueNode; + delete overridableKeys[keyNode]; + } + + return _result; +} + +function readLineBreak(state) { + var ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x0A/* LF */) { + state.position++; + } else if (ch === 0x0D/* CR */) { + state.position++; + if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { + state.position++; + } + } else { + throwError(state, 'a line break is expected'); + } + + state.line += 1; + state.lineStart = state.position; +} + +function skipSeparationSpace(state, allowComments, checkIndent) { + var lineBreaks = 0, + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (allowComments && ch === 0x23/* # */) { + do { + ch = state.input.charCodeAt(++state.position); + } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); + } + + if (is_EOL(ch)) { + readLineBreak(state); + + ch = state.input.charCodeAt(state.position); + lineBreaks++; + state.lineIndent = 0; + + while (ch === 0x20/* Space */) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } + } else { + break; + } + } + + if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { + throwWarning(state, 'deficient indentation'); + } + + return lineBreaks; +} + +function testDocumentSeparator(state) { + var _position = state.position, + ch; + + ch = state.input.charCodeAt(_position); + + // Condition state.position === state.lineStart is tested + // in parent on each call, for efficiency. No needs to test here again. + if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && + ch === state.input.charCodeAt(_position + 1) && + ch === state.input.charCodeAt(_position + 2)) { + + _position += 3; + + ch = state.input.charCodeAt(_position); + + if (ch === 0 || is_WS_OR_EOL(ch)) { + return true; + } + } + + return false; +} + +function writeFoldedLines(state, count) { + if (count === 1) { + state.result += ' '; + } else if (count > 1) { + state.result += common.repeat('\n', count - 1); + } +} + + +function readPlainScalar(state, nodeIndent, withinFlowCollection) { + var preceding, + following, + captureStart, + captureEnd, + hasPendingContent, + _line, + _lineStart, + _lineIndent, + _kind = state.kind, + _result = state.result, + ch; + + ch = state.input.charCodeAt(state.position); + + if (is_WS_OR_EOL(ch) || + is_FLOW_INDICATOR(ch) || + ch === 0x23/* # */ || + ch === 0x26/* & */ || + ch === 0x2A/* * */ || + ch === 0x21/* ! */ || + ch === 0x7C/* | */ || + ch === 0x3E/* > */ || + ch === 0x27/* ' */ || + ch === 0x22/* " */ || + ch === 0x25/* % */ || + ch === 0x40/* @ */ || + ch === 0x60/* ` */) { + return false; + } + + if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + return false; + } + } + + state.kind = 'scalar'; + state.result = ''; + captureStart = captureEnd = state.position; + hasPendingContent = false; + + while (ch !== 0) { + if (ch === 0x3A/* : */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + break; + } + + } else if (ch === 0x23/* # */) { + preceding = state.input.charCodeAt(state.position - 1); + + if (is_WS_OR_EOL(preceding)) { + break; + } + + } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || + withinFlowCollection && is_FLOW_INDICATOR(ch)) { + break; + + } else if (is_EOL(ch)) { + _line = state.line; + _lineStart = state.lineStart; + _lineIndent = state.lineIndent; + skipSeparationSpace(state, false, -1); + + if (state.lineIndent >= nodeIndent) { + hasPendingContent = true; + ch = state.input.charCodeAt(state.position); + continue; + } else { + state.position = captureEnd; + state.line = _line; + state.lineStart = _lineStart; + state.lineIndent = _lineIndent; + break; + } + } + + if (hasPendingContent) { + captureSegment(state, captureStart, captureEnd, false); + writeFoldedLines(state, state.line - _line); + captureStart = captureEnd = state.position; + hasPendingContent = false; + } + + if (!is_WHITE_SPACE(ch)) { + captureEnd = state.position + 1; + } + + ch = state.input.charCodeAt(++state.position); + } + + captureSegment(state, captureStart, captureEnd, false); + + if (state.result) { + return true; + } + + state.kind = _kind; + state.result = _result; + return false; +} + +function readSingleQuotedScalar(state, nodeIndent) { + var ch, + captureStart, captureEnd; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x27/* ' */) { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x27/* ' */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x27/* ' */) { + captureStart = state.position; + state.position++; + captureEnd = state.position; + } else { + return true; + } + + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; + + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a single quoted scalar'); + + } else { + state.position++; + captureEnd = state.position; + } + } + + throwError(state, 'unexpected end of the stream within a single quoted scalar'); +} + +function readDoubleQuotedScalar(state, nodeIndent) { + var captureStart, + captureEnd, + hexLength, + hexResult, + tmp, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x22/* " */) { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x22/* " */) { + captureSegment(state, captureStart, state.position, true); + state.position++; + return true; + + } else if (ch === 0x5C/* \ */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); + + if (is_EOL(ch)) { + skipSeparationSpace(state, false, nodeIndent); + + // TODO: rework to inline fn with no type cast? + } else if (ch < 256 && simpleEscapeCheck[ch]) { + state.result += simpleEscapeMap[ch]; + state.position++; + + } else if ((tmp = escapedHexLen(ch)) > 0) { + hexLength = tmp; + hexResult = 0; + + for (; hexLength > 0; hexLength--) { + ch = state.input.charCodeAt(++state.position); + + if ((tmp = fromHexCode(ch)) >= 0) { + hexResult = (hexResult << 4) + tmp; + + } else { + throwError(state, 'expected hexadecimal character'); + } + } + + state.result += charFromCodepoint(hexResult); + + state.position++; + + } else { + throwError(state, 'unknown escape sequence'); + } + + captureStart = captureEnd = state.position; + + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; + + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a double quoted scalar'); + + } else { + state.position++; + captureEnd = state.position; + } + } + + throwError(state, 'unexpected end of the stream within a double quoted scalar'); +} + +function readFlowCollection(state, nodeIndent) { + var readNext = true, + _line, + _tag = state.tag, + _result, + _anchor = state.anchor, + following, + terminator, + isPair, + isExplicitPair, + isMapping, + overridableKeys = {}, + keyNode, + keyTag, + valueNode, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x5B/* [ */) { + terminator = 0x5D;/* ] */ + isMapping = false; + _result = []; + } else if (ch === 0x7B/* { */) { + terminator = 0x7D;/* } */ + isMapping = true; + _result = {}; + } else { + return false; + } + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(++state.position); + + while (ch !== 0) { + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if (ch === terminator) { + state.position++; + state.tag = _tag; + state.anchor = _anchor; + state.kind = isMapping ? 'mapping' : 'sequence'; + state.result = _result; + return true; + } else if (!readNext) { + throwError(state, 'missed comma between flow collection entries'); + } + + keyTag = keyNode = valueNode = null; + isPair = isExplicitPair = false; + + if (ch === 0x3F/* ? */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following)) { + isPair = isExplicitPair = true; + state.position++; + skipSeparationSpace(state, true, nodeIndent); + } + } + + _line = state.line; + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + keyTag = state.tag; + keyNode = state.result; + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { + isPair = true; + ch = state.input.charCodeAt(++state.position); + skipSeparationSpace(state, true, nodeIndent); + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + valueNode = state.result; + } + + if (isMapping) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode); + } else if (isPair) { + _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode)); + } else { + _result.push(keyNode); + } + + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x2C/* , */) { + readNext = true; + ch = state.input.charCodeAt(++state.position); + } else { + readNext = false; + } + } + + throwError(state, 'unexpected end of the stream within a flow collection'); +} + +function readBlockScalar(state, nodeIndent) { + var captureStart, + folding, + chomping = CHOMPING_CLIP, + didReadContent = false, + detectedIndent = false, + textIndent = nodeIndent, + emptyLines = 0, + atMoreIndented = false, + tmp, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x7C/* | */) { + folding = false; + } else if (ch === 0x3E/* > */) { + folding = true; + } else { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + + while (ch !== 0) { + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { + if (CHOMPING_CLIP === chomping) { + chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; + } else { + throwError(state, 'repeat of a chomping mode identifier'); + } + + } else if ((tmp = fromDecimalCode(ch)) >= 0) { + if (tmp === 0) { + throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); + } else if (!detectedIndent) { + textIndent = nodeIndent + tmp - 1; + detectedIndent = true; + } else { + throwError(state, 'repeat of an indentation width identifier'); + } + + } else { + break; + } + } + + if (is_WHITE_SPACE(ch)) { + do { ch = state.input.charCodeAt(++state.position); } + while (is_WHITE_SPACE(ch)); + + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (!is_EOL(ch) && (ch !== 0)); + } + } + + while (ch !== 0) { + readLineBreak(state); + state.lineIndent = 0; + + ch = state.input.charCodeAt(state.position); + + while ((!detectedIndent || state.lineIndent < textIndent) && + (ch === 0x20/* Space */)) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } + + if (!detectedIndent && state.lineIndent > textIndent) { + textIndent = state.lineIndent; + } + + if (is_EOL(ch)) { + emptyLines++; + continue; + } + + // End of the scalar. + if (state.lineIndent < textIndent) { + + // Perform the chomping. + if (chomping === CHOMPING_KEEP) { + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } else if (chomping === CHOMPING_CLIP) { + if (didReadContent) { // i.e. only if the scalar is not empty. + state.result += '\n'; + } + } + + // Break this `while` cycle and go to the funciton's epilogue. + break; + } + + // Folded style: use fancy rules to handle line breaks. + if (folding) { + + // Lines starting with white space characters (more-indented lines) are not folded. + if (is_WHITE_SPACE(ch)) { + atMoreIndented = true; + // except for the first content line (cf. Example 8.1) + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + + // End of more-indented block. + } else if (atMoreIndented) { + atMoreIndented = false; + state.result += common.repeat('\n', emptyLines + 1); + + // Just one line break - perceive as the same line. + } else if (emptyLines === 0) { + if (didReadContent) { // i.e. only if we have already read some scalar content. + state.result += ' '; + } + + // Several line breaks - perceive as different lines. + } else { + state.result += common.repeat('\n', emptyLines); + } + + // Literal style: just add exact number of line breaks between content lines. + } else { + // Keep all line breaks except the header line break. + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } + + didReadContent = true; + detectedIndent = true; + emptyLines = 0; + captureStart = state.position; + + while (!is_EOL(ch) && (ch !== 0)) { + ch = state.input.charCodeAt(++state.position); + } + + captureSegment(state, captureStart, state.position, false); + } + + return true; +} + +function readBlockSequence(state, nodeIndent) { + var _line, + _tag = state.tag, + _anchor = state.anchor, + _result = [], + following, + detected = false, + ch; + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + + if (ch !== 0x2D/* - */) { + break; + } + + following = state.input.charCodeAt(state.position + 1); + + if (!is_WS_OR_EOL(following)) { + break; + } + + detected = true; + state.position++; + + if (skipSeparationSpace(state, true, -1)) { + if (state.lineIndent <= nodeIndent) { + _result.push(null); + ch = state.input.charCodeAt(state.position); + continue; + } + } + + _line = state.line; + composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); + _result.push(state.result); + skipSeparationSpace(state, true, -1); + + ch = state.input.charCodeAt(state.position); + + if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { + throwError(state, 'bad indentation of a sequence entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } + } + + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'sequence'; + state.result = _result; + return true; + } + return false; +} + +function readBlockMapping(state, nodeIndent, flowIndent) { + var following, + allowCompact, + _line, + _pos, + _tag = state.tag, + _anchor = state.anchor, + _result = {}, + overridableKeys = {}, + keyTag = null, + keyNode = null, + valueNode = null, + atExplicitKey = false, + detected = false, + ch; + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + following = state.input.charCodeAt(state.position + 1); + _line = state.line; // Save the current line. + _pos = state.position; + + // + // Explicit notation case. There are two separate blocks: + // first for the key (denoted by "?") and second for the value (denoted by ":") + // + if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { + + if (ch === 0x3F/* ? */) { + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); + keyTag = keyNode = valueNode = null; + } + + detected = true; + atExplicitKey = true; + allowCompact = true; + + } else if (atExplicitKey) { + // i.e. 0x3A/* : */ === character after the explicit key. + atExplicitKey = false; + allowCompact = true; + + } else { + throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); + } + + state.position += 1; + ch = following; + + // + // Implicit notation case. Flow-style node as the key first, then ":", and the value. + // + } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { + + if (state.line === _line) { + ch = state.input.charCodeAt(state.position); + + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (ch === 0x3A/* : */) { + ch = state.input.charCodeAt(++state.position); + + if (!is_WS_OR_EOL(ch)) { + throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); + } + + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); + keyTag = keyNode = valueNode = null; + } + + detected = true; + atExplicitKey = false; + allowCompact = false; + keyTag = state.tag; + keyNode = state.result; + + } else if (detected) { + throwError(state, 'can not read an implicit mapping pair; a colon is missed'); + + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } + + } else if (detected) { + throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); + + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } + + } else { + break; // Reading is done. Go to the epilogue. + } + + // + // Common reading code for both explicit and implicit notations. + // + if (state.line === _line || state.lineIndent > nodeIndent) { + if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { + if (atExplicitKey) { + keyNode = state.result; + } else { + valueNode = state.result; + } + } + + if (!atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos); + keyTag = keyNode = valueNode = null; + } + + skipSeparationSpace(state, true, -1); + ch = state.input.charCodeAt(state.position); + } + + if (state.lineIndent > nodeIndent && (ch !== 0)) { + throwError(state, 'bad indentation of a mapping entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } + } + + // + // Epilogue. + // + + // Special case: last mapping's node contains only the key in explicit notation. + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); + } + + // Expose the resulting mapping. + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'mapping'; + state.result = _result; + } + + return detected; +} + +function readTagProperty(state) { + var _position, + isVerbatim = false, + isNamed = false, + tagHandle, + tagName, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x21/* ! */) return false; + + if (state.tag !== null) { + throwError(state, 'duplication of a tag property'); + } + + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x3C/* < */) { + isVerbatim = true; + ch = state.input.charCodeAt(++state.position); + + } else if (ch === 0x21/* ! */) { + isNamed = true; + tagHandle = '!!'; + ch = state.input.charCodeAt(++state.position); + + } else { + tagHandle = '!'; + } + + _position = state.position; + + if (isVerbatim) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && ch !== 0x3E/* > */); + + if (state.position < state.length) { + tagName = state.input.slice(_position, state.position); + ch = state.input.charCodeAt(++state.position); + } else { + throwError(state, 'unexpected end of the stream within a verbatim tag'); + } + } else { + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + + if (ch === 0x21/* ! */) { + if (!isNamed) { + tagHandle = state.input.slice(_position - 1, state.position + 1); + + if (!PATTERN_TAG_HANDLE.test(tagHandle)) { + throwError(state, 'named tag handle cannot contain such characters'); + } + + isNamed = true; + _position = state.position + 1; + } else { + throwError(state, 'tag suffix cannot contain exclamation marks'); + } + } + + ch = state.input.charCodeAt(++state.position); + } + + tagName = state.input.slice(_position, state.position); + + if (PATTERN_FLOW_INDICATORS.test(tagName)) { + throwError(state, 'tag suffix cannot contain flow indicator characters'); + } + } + + if (tagName && !PATTERN_TAG_URI.test(tagName)) { + throwError(state, 'tag name cannot contain such characters: ' + tagName); + } + + if (isVerbatim) { + state.tag = tagName; + + } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) { + state.tag = state.tagMap[tagHandle] + tagName; + + } else if (tagHandle === '!') { + state.tag = '!' + tagName; + + } else if (tagHandle === '!!') { + state.tag = 'tag:yaml.org,2002:' + tagName; + + } else { + throwError(state, 'undeclared tag handle "' + tagHandle + '"'); + } + + return true; +} + +function readAnchorProperty(state) { + var _position, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x26/* & */) return false; + + if (state.anchor !== null) { + throwError(state, 'duplication of an anchor property'); + } + + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (state.position === _position) { + throwError(state, 'name of an anchor node must contain at least one character'); + } + + state.anchor = state.input.slice(_position, state.position); + return true; +} + +function readAlias(state) { + var _position, alias, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x2A/* * */) return false; + + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (state.position === _position) { + throwError(state, 'name of an alias node must contain at least one character'); + } + + alias = state.input.slice(_position, state.position); + + if (!state.anchorMap.hasOwnProperty(alias)) { + throwError(state, 'unidentified alias "' + alias + '"'); + } + + state.result = state.anchorMap[alias]; + skipSeparationSpace(state, true, -1); + return true; +} + +function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { + var allowBlockStyles, + allowBlockScalars, + allowBlockCollections, + indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; + } + } + } + + if (indentStatus === 1) { + while (readTagProperty(state) || readAnchorProperty(state)) { + if (skipSeparationSpace(state, true, -1)) { + atNewLine = true; + allowBlockCollections = allowBlockStyles; + + if (state.lineIndent > parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; + } + } else { + allowBlockCollections = false; + } + } + } + + if (allowBlockCollections) { + allowBlockCollections = atNewLine || allowCompact; + } + + if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { + if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { + flowIndent = parentIndent; + } else { + flowIndent = parentIndent + 1; + } + + blockIndent = state.position - state.lineStart; + + if (indentStatus === 1) { + if (allowBlockCollections && + (readBlockSequence(state, blockIndent) || + readBlockMapping(state, blockIndent, flowIndent)) || + readFlowCollection(state, flowIndent)) { + hasContent = true; + } else { + if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || + readSingleQuotedScalar(state, flowIndent) || + readDoubleQuotedScalar(state, flowIndent)) { + hasContent = true; + + } else if (readAlias(state)) { + hasContent = true; + + if (state.tag !== null || state.anchor !== null) { + throwError(state, 'alias node should not have any properties'); + } + + } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { + hasContent = true; + + if (state.tag === null) { + state.tag = '?'; + } + } + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + } + } else if (indentStatus === 0) { + // Special case: block sequences are allowed to have same indentation level as the parent. + // http://www.yaml.org/spec/1.2/spec.html#id2799784 + hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); + } + } + + if (state.tag !== null && state.tag !== '!') { + if (state.tag === '?') { + for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { + type = state.implicitTypes[typeIndex]; + + // Implicit resolving is not allowed for non-scalar types, and '?' + // non-specific tag is only assigned to plain scalars. So, it isn't + // needed to check for 'kind' conformity. + + if (type.resolve(state.result)) { // `state.result` updated in resolver if matched + state.result = type.construct(state.result); + state.tag = type.tag; + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + break; + } + } + } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) { + type = state.typeMap[state.kind || 'fallback'][state.tag]; + + if (state.result !== null && type.kind !== state.kind) { + throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); + } + + if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched + throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); + } else { + state.result = type.construct(state.result); + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + } + } else { + throwError(state, 'unknown tag !<' + state.tag + '>'); + } + } + + if (state.listener !== null) { + state.listener('close', state); + } + return state.tag !== null || state.anchor !== null || hasContent; +} + +function readDocument(state) { + var documentStart = state.position, + _position, + directiveName, + directiveArgs, + hasDirectives = false, + ch; + + state.version = null; + state.checkLineBreaks = state.legacy; + state.tagMap = {}; + state.anchorMap = {}; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + skipSeparationSpace(state, true, -1); + + ch = state.input.charCodeAt(state.position); + + if (state.lineIndent > 0 || ch !== 0x25/* % */) { + break; + } + + hasDirectives = true; + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + directiveName = state.input.slice(_position, state.position); + directiveArgs = []; + + if (directiveName.length < 1) { + throwError(state, 'directive name must not be less than one character in length'); + } + + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && !is_EOL(ch)); + break; + } + + if (is_EOL(ch)) break; + + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + directiveArgs.push(state.input.slice(_position, state.position)); + } + + if (ch !== 0) readLineBreak(state); + + if (_hasOwnProperty.call(directiveHandlers, directiveName)) { + directiveHandlers[directiveName](state, directiveName, directiveArgs); + } else { + throwWarning(state, 'unknown document directive "' + directiveName + '"'); + } + } + + skipSeparationSpace(state, true, -1); + + if (state.lineIndent === 0 && + state.input.charCodeAt(state.position) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { + state.position += 3; + skipSeparationSpace(state, true, -1); + + } else if (hasDirectives) { + throwError(state, 'directives end mark is expected'); + } + + composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); + skipSeparationSpace(state, true, -1); + + if (state.checkLineBreaks && + PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { + throwWarning(state, 'non-ASCII line breaks are interpreted as content'); + } + + state.documents.push(state.result); + + if (state.position === state.lineStart && testDocumentSeparator(state)) { + + if (state.input.charCodeAt(state.position) === 0x2E/* . */) { + state.position += 3; + skipSeparationSpace(state, true, -1); + } + return; + } + + if (state.position < (state.length - 1)) { + throwError(state, 'end of the stream or a document separator is expected'); + } else { + return; + } +} + + +function loadDocuments(input, options) { + input = String(input); + options = options || {}; + + if (input.length !== 0) { + + // Add tailing `\n` if not exists + if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && + input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { + input += '\n'; + } + + // Strip BOM + if (input.charCodeAt(0) === 0xFEFF) { + input = input.slice(1); + } + } + + var state = new State(input, options); + + // Use 0 as string terminator. That significantly simplifies bounds check. + state.input += '\0'; + + while (state.input.charCodeAt(state.position) === 0x20/* Space */) { + state.lineIndent += 1; + state.position += 1; + } + + while (state.position < (state.length - 1)) { + readDocument(state); + } + + return state.documents; +} + + +function loadAll(input, iterator, options) { + var documents = loadDocuments(input, options), index, length; + + if (typeof iterator !== 'function') { + return documents; + } + + for (index = 0, length = documents.length; index < length; index += 1) { + iterator(documents[index]); + } +} + + +function load(input, options) { + var documents = loadDocuments(input, options); + + if (documents.length === 0) { + /*eslint-disable no-undefined*/ + return undefined; + } else if (documents.length === 1) { + return documents[0]; + } + throw new YAMLException('expected a single document in the stream, but found more'); +} + + +function safeLoadAll(input, output, options) { + if (typeof output === 'function') { + loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); + } else { + return loadAll(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); + } +} + + +function safeLoad(input, options) { + return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); +} + + +module.exports.loadAll = loadAll; +module.exports.load = load; +module.exports.safeLoadAll = safeLoadAll; +module.exports.safeLoad = safeLoad; + +},{"./common":2,"./exception":4,"./mark":6,"./schema/default_full":9,"./schema/default_safe":10}],6:[function(require,module,exports){ +'use strict'; + + +var common = require('./common'); + + +function Mark(name, buffer, position, line, column) { + this.name = name; + this.buffer = buffer; + this.position = position; + this.line = line; + this.column = column; +} + + +Mark.prototype.getSnippet = function getSnippet(indent, maxLength) { + var head, start, tail, end, snippet; + + if (!this.buffer) return null; + + indent = indent || 4; + maxLength = maxLength || 75; + + head = ''; + start = this.position; + + while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) { + start -= 1; + if (this.position - start > (maxLength / 2 - 1)) { + head = ' ... '; + start += 5; + break; + } + } + + tail = ''; + end = this.position; + + while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) { + end += 1; + if (end - this.position > (maxLength / 2 - 1)) { + tail = ' ... '; + end -= 5; + break; + } + } + + snippet = this.buffer.slice(start, end); + + return common.repeat(' ', indent) + head + snippet + tail + '\n' + + common.repeat(' ', indent + this.position - start + head.length) + '^'; +}; + + +Mark.prototype.toString = function toString(compact) { + var snippet, where = ''; + + if (this.name) { + where += 'in "' + this.name + '" '; + } + + where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1); + + if (!compact) { + snippet = this.getSnippet(); + + if (snippet) { + where += ':\n' + snippet; + } + } + + return where; +}; + + +module.exports = Mark; + +},{"./common":2}],7:[function(require,module,exports){ +'use strict'; + +/*eslint-disable max-len*/ + +var common = require('./common'); +var YAMLException = require('./exception'); +var Type = require('./type'); + + +function compileList(schema, name, result) { + var exclude = []; + + schema.include.forEach(function (includedSchema) { + result = compileList(includedSchema, name, result); + }); + + schema[name].forEach(function (currentType) { + result.forEach(function (previousType, previousIndex) { + if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) { + exclude.push(previousIndex); + } + }); + + result.push(currentType); + }); + + return result.filter(function (type, index) { + return exclude.indexOf(index) === -1; + }); +} + + +function compileMap(/* lists... */) { + var result = { + scalar: {}, + sequence: {}, + mapping: {}, + fallback: {} + }, index, length; + + function collectType(type) { + result[type.kind][type.tag] = result['fallback'][type.tag] = type; + } + + for (index = 0, length = arguments.length; index < length; index += 1) { + arguments[index].forEach(collectType); + } + return result; +} + + +function Schema(definition) { + this.include = definition.include || []; + this.implicit = definition.implicit || []; + this.explicit = definition.explicit || []; + + this.implicit.forEach(function (type) { + if (type.loadKind && type.loadKind !== 'scalar') { + throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); + } + }); + + this.compiledImplicit = compileList(this, 'implicit', []); + this.compiledExplicit = compileList(this, 'explicit', []); + this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit); +} + + +Schema.DEFAULT = null; + + +Schema.create = function createSchema() { + var schemas, types; + + switch (arguments.length) { + case 1: + schemas = Schema.DEFAULT; + types = arguments[0]; + break; + + case 2: + schemas = arguments[0]; + types = arguments[1]; + break; + + default: + throw new YAMLException('Wrong number of arguments for Schema.create function'); + } + + schemas = common.toArray(schemas); + types = common.toArray(types); + + if (!schemas.every(function (schema) { return schema instanceof Schema; })) { + throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.'); + } + + if (!types.every(function (type) { return type instanceof Type; })) { + throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + } + + return new Schema({ + include: schemas, + explicit: types + }); +}; + + +module.exports = Schema; + +},{"./common":2,"./exception":4,"./type":13}],8:[function(require,module,exports){ +// Standard YAML's Core schema. +// http://www.yaml.org/spec/1.2/spec.html#id2804923 +// +// NOTE: JS-YAML does not support schema-specific tag resolution restrictions. +// So, Core schema has no distinctions from JSON schema is JS-YAML. + + +'use strict'; + + +var Schema = require('../schema'); + + +module.exports = new Schema({ + include: [ + require('./json') + ] +}); + +},{"../schema":7,"./json":12}],9:[function(require,module,exports){ +// JS-YAML's default schema for `load` function. +// It is not described in the YAML specification. +// +// This schema is based on JS-YAML's default safe schema and includes +// JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function. +// +// Also this schema is used as default base schema at `Schema.create` function. + + +'use strict'; + + +var Schema = require('../schema'); + + +module.exports = Schema.DEFAULT = new Schema({ + include: [ + require('./default_safe') + ], + explicit: [ + require('../type/js/undefined'), + require('../type/js/regexp'), + require('../type/js/function') + ] +}); + +},{"../schema":7,"../type/js/function":18,"../type/js/regexp":19,"../type/js/undefined":20,"./default_safe":10}],10:[function(require,module,exports){ +// JS-YAML's default schema for `safeLoad` function. +// It is not described in the YAML specification. +// +// This schema is based on standard YAML's Core schema and includes most of +// extra types described at YAML tag repository. (http://yaml.org/type/) + + +'use strict'; + + +var Schema = require('../schema'); + + +module.exports = new Schema({ + include: [ + require('./core') + ], + implicit: [ + require('../type/timestamp'), + require('../type/merge') + ], + explicit: [ + require('../type/binary'), + require('../type/omap'), + require('../type/pairs'), + require('../type/set') + ] +}); + +},{"../schema":7,"../type/binary":14,"../type/merge":22,"../type/omap":24,"../type/pairs":25,"../type/set":27,"../type/timestamp":29,"./core":8}],11:[function(require,module,exports){ +// Standard YAML's Failsafe schema. +// http://www.yaml.org/spec/1.2/spec.html#id2802346 + + +'use strict'; + + +var Schema = require('../schema'); + + +module.exports = new Schema({ + explicit: [ + require('../type/str'), + require('../type/seq'), + require('../type/map') + ] +}); + +},{"../schema":7,"../type/map":21,"../type/seq":26,"../type/str":28}],12:[function(require,module,exports){ +// Standard YAML's JSON schema. +// http://www.yaml.org/spec/1.2/spec.html#id2803231 +// +// NOTE: JS-YAML does not support schema-specific tag resolution restrictions. +// So, this schema is not such strict as defined in the YAML specification. +// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc. + + +'use strict'; + + +var Schema = require('../schema'); + + +module.exports = new Schema({ + include: [ + require('./failsafe') + ], + implicit: [ + require('../type/null'), + require('../type/bool'), + require('../type/int'), + require('../type/float') + ] +}); + +},{"../schema":7,"../type/bool":15,"../type/float":16,"../type/int":17,"../type/null":23,"./failsafe":11}],13:[function(require,module,exports){ +'use strict'; + +var YAMLException = require('./exception'); + +var TYPE_CONSTRUCTOR_OPTIONS = [ + 'kind', + 'resolve', + 'construct', + 'instanceOf', + 'predicate', + 'represent', + 'defaultStyle', + 'styleAliases' +]; + +var YAML_NODE_KINDS = [ + 'scalar', + 'sequence', + 'mapping' +]; + +function compileStyleAliases(map) { + var result = {}; + + if (map !== null) { + Object.keys(map).forEach(function (style) { + map[style].forEach(function (alias) { + result[String(alias)] = style; + }); + }); + } + + return result; +} + +function Type(tag, options) { + options = options || {}; + + Object.keys(options).forEach(function (name) { + if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { + throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); + } + }); + + // TODO: Add tag format check. + this.tag = tag; + this.kind = options['kind'] || null; + this.resolve = options['resolve'] || function () { return true; }; + this.construct = options['construct'] || function (data) { return data; }; + this.instanceOf = options['instanceOf'] || null; + this.predicate = options['predicate'] || null; + this.represent = options['represent'] || null; + this.defaultStyle = options['defaultStyle'] || null; + this.styleAliases = compileStyleAliases(options['styleAliases'] || null); + + if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { + throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); + } +} + +module.exports = Type; + +},{"./exception":4}],14:[function(require,module,exports){ +'use strict'; + +/*eslint-disable no-bitwise*/ + +var NodeBuffer; + +try { + // A trick for browserified version, to not include `Buffer` shim + var _require = require; + NodeBuffer = _require('buffer').Buffer; +} catch (__) {} + +var Type = require('../type'); + + +// [ 64, 65, 66 ] -> [ padding, CR, LF ] +var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; + + +function resolveYamlBinary(data) { + if (data === null) return false; + + var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; + + // Convert one by one. + for (idx = 0; idx < max; idx++) { + code = map.indexOf(data.charAt(idx)); + + // Skip CR/LF + if (code > 64) continue; + + // Fail on illegal characters + if (code < 0) return false; + + bitlen += 6; + } + + // If there are any bits left, source was corrupted + return (bitlen % 8) === 0; +} + +function constructYamlBinary(data) { + var idx, tailbits, + input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan + max = input.length, + map = BASE64_MAP, + bits = 0, + result = []; + + // Collect by 6*4 bits (3 bytes) + + for (idx = 0; idx < max; idx++) { + if ((idx % 4 === 0) && idx) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); + } + + bits = (bits << 6) | map.indexOf(input.charAt(idx)); + } + + // Dump tail + + tailbits = (max % 4) * 6; + + if (tailbits === 0) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); + } else if (tailbits === 18) { + result.push((bits >> 10) & 0xFF); + result.push((bits >> 2) & 0xFF); + } else if (tailbits === 12) { + result.push((bits >> 4) & 0xFF); + } + + // Wrap into Buffer for NodeJS and leave Array for browser + if (NodeBuffer) { + // Support node 6.+ Buffer API when available + return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result); + } + + return result; +} + +function representYamlBinary(object /*, style*/) { + var result = '', bits = 0, idx, tail, + max = object.length, + map = BASE64_MAP; + + // Convert every three bytes to 4 ASCII characters. + + for (idx = 0; idx < max; idx++) { + if ((idx % 3 === 0) && idx) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } + + bits = (bits << 8) + object[idx]; + } + + // Dump tail + + tail = max % 3; + + if (tail === 0) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } else if (tail === 2) { + result += map[(bits >> 10) & 0x3F]; + result += map[(bits >> 4) & 0x3F]; + result += map[(bits << 2) & 0x3F]; + result += map[64]; + } else if (tail === 1) { + result += map[(bits >> 2) & 0x3F]; + result += map[(bits << 4) & 0x3F]; + result += map[64]; + result += map[64]; + } + + return result; +} + +function isBinary(object) { + return NodeBuffer && NodeBuffer.isBuffer(object); +} + +module.exports = new Type('tag:yaml.org,2002:binary', { + kind: 'scalar', + resolve: resolveYamlBinary, + construct: constructYamlBinary, + predicate: isBinary, + represent: representYamlBinary +}); + +},{"../type":13}],15:[function(require,module,exports){ +'use strict'; + +var Type = require('../type'); + +function resolveYamlBoolean(data) { + if (data === null) return false; + + var max = data.length; + + return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || + (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); +} + +function constructYamlBoolean(data) { + return data === 'true' || + data === 'True' || + data === 'TRUE'; +} + +function isBoolean(object) { + return Object.prototype.toString.call(object) === '[object Boolean]'; +} + +module.exports = new Type('tag:yaml.org,2002:bool', { + kind: 'scalar', + resolve: resolveYamlBoolean, + construct: constructYamlBoolean, + predicate: isBoolean, + represent: { + lowercase: function (object) { return object ? 'true' : 'false'; }, + uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, + camelcase: function (object) { return object ? 'True' : 'False'; } + }, + defaultStyle: 'lowercase' +}); + +},{"../type":13}],16:[function(require,module,exports){ +'use strict'; + +var common = require('../common'); +var Type = require('../type'); + +var YAML_FLOAT_PATTERN = new RegExp( + // 2.5e4, 2.5 and integers + '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + + // .2e4, .2 + // special case, seems not from spec + '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + + // 20:59 + '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' + + // .inf + '|[-+]?\\.(?:inf|Inf|INF)' + + // .nan + '|\\.(?:nan|NaN|NAN))$'); + +function resolveYamlFloat(data) { + if (data === null) return false; + + if (!YAML_FLOAT_PATTERN.test(data) || + // Quick hack to not allow integers end with `_` + // Probably should update regexp & check speed + data[data.length - 1] === '_') { + return false; + } + + return true; +} + +function constructYamlFloat(data) { + var value, sign, base, digits; + + value = data.replace(/_/g, '').toLowerCase(); + sign = value[0] === '-' ? -1 : 1; + digits = []; + + if ('+-'.indexOf(value[0]) >= 0) { + value = value.slice(1); + } + + if (value === '.inf') { + return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; + + } else if (value === '.nan') { + return NaN; + + } else if (value.indexOf(':') >= 0) { + value.split(':').forEach(function (v) { + digits.unshift(parseFloat(v, 10)); + }); + + value = 0.0; + base = 1; + + digits.forEach(function (d) { + value += d * base; + base *= 60; + }); + + return sign * value; + + } + return sign * parseFloat(value, 10); +} + + +var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; + +function representYamlFloat(object, style) { + var res; + + if (isNaN(object)) { + switch (style) { + case 'lowercase': return '.nan'; + case 'uppercase': return '.NAN'; + case 'camelcase': return '.NaN'; + } + } else if (Number.POSITIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '.inf'; + case 'uppercase': return '.INF'; + case 'camelcase': return '.Inf'; + } + } else if (Number.NEGATIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '-.inf'; + case 'uppercase': return '-.INF'; + case 'camelcase': return '-.Inf'; + } + } else if (common.isNegativeZero(object)) { + return '-0.0'; + } + + res = object.toString(10); + + // JS stringifier can build scientific format without dots: 5e-100, + // while YAML requres dot: 5.e-100. Fix it with simple hack + + return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; +} + +function isFloat(object) { + return (Object.prototype.toString.call(object) === '[object Number]') && + (object % 1 !== 0 || common.isNegativeZero(object)); +} + +module.exports = new Type('tag:yaml.org,2002:float', { + kind: 'scalar', + resolve: resolveYamlFloat, + construct: constructYamlFloat, + predicate: isFloat, + represent: representYamlFloat, + defaultStyle: 'lowercase' +}); + +},{"../common":2,"../type":13}],17:[function(require,module,exports){ +'use strict'; + +var common = require('../common'); +var Type = require('../type'); + +function isHexCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || + ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || + ((0x61/* a */ <= c) && (c <= 0x66/* f */)); +} + +function isOctCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); +} + +function isDecCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); +} + +function resolveYamlInteger(data) { + if (data === null) return false; + + var max = data.length, + index = 0, + hasDigits = false, + ch; + + if (!max) return false; + + ch = data[index]; + + // sign + if (ch === '-' || ch === '+') { + ch = data[++index]; + } + + if (ch === '0') { + // 0 + if (index + 1 === max) return true; + ch = data[++index]; + + // base 2, base 8, base 16 + + if (ch === 'b') { + // base 2 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (ch !== '0' && ch !== '1') return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + + + if (ch === 'x') { + // base 16 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isHexCode(data.charCodeAt(index))) return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + + // base 8 + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isOctCode(data.charCodeAt(index))) return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + + // base 10 (except 0) or base 60 + + // value should not start with `_`; + if (ch === '_') return false; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (ch === ':') break; + if (!isDecCode(data.charCodeAt(index))) { + return false; + } + hasDigits = true; + } + + // Should have digits and should not end with `_` + if (!hasDigits || ch === '_') return false; + + // if !base60 - done; + if (ch !== ':') return true; + + // base60 almost not used, no needs to optimize + return /^(:[0-5]?[0-9])+$/.test(data.slice(index)); +} + +function constructYamlInteger(data) { + var value = data, sign = 1, ch, base, digits = []; + + if (value.indexOf('_') !== -1) { + value = value.replace(/_/g, ''); + } + + ch = value[0]; + + if (ch === '-' || ch === '+') { + if (ch === '-') sign = -1; + value = value.slice(1); + ch = value[0]; + } + + if (value === '0') return 0; + + if (ch === '0') { + if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); + if (value[1] === 'x') return sign * parseInt(value, 16); + return sign * parseInt(value, 8); + } + + if (value.indexOf(':') !== -1) { + value.split(':').forEach(function (v) { + digits.unshift(parseInt(v, 10)); + }); + + value = 0; + base = 1; + + digits.forEach(function (d) { + value += (d * base); + base *= 60; + }); + + return sign * value; + + } + + return sign * parseInt(value, 10); +} + +function isInteger(object) { + return (Object.prototype.toString.call(object)) === '[object Number]' && + (object % 1 === 0 && !common.isNegativeZero(object)); +} + +module.exports = new Type('tag:yaml.org,2002:int', { + kind: 'scalar', + resolve: resolveYamlInteger, + construct: constructYamlInteger, + predicate: isInteger, + represent: { + binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, + octal: function (obj) { return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1); }, + decimal: function (obj) { return obj.toString(10); }, + /* eslint-disable max-len */ + hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } + }, + defaultStyle: 'decimal', + styleAliases: { + binary: [ 2, 'bin' ], + octal: [ 8, 'oct' ], + decimal: [ 10, 'dec' ], + hexadecimal: [ 16, 'hex' ] + } +}); + +},{"../common":2,"../type":13}],18:[function(require,module,exports){ +'use strict'; + +var esprima; + +// Browserified version does not have esprima +// +// 1. For node.js just require module as deps +// 2. For browser try to require mudule via external AMD system. +// If not found - try to fallback to window.esprima. If not +// found too - then fail to parse. +// +try { + // workaround to exclude package from browserify list. + var _require = require; + esprima = _require('esprima'); +} catch (_) { + /*global window */ + if (typeof window !== 'undefined') esprima = window.esprima; +} + +var Type = require('../../type'); + +function resolveJavascriptFunction(data) { + if (data === null) return false; + + try { + var source = '(' + data + ')', + ast = esprima.parse(source, { range: true }); + + if (ast.type !== 'Program' || + ast.body.length !== 1 || + ast.body[0].type !== 'ExpressionStatement' || + (ast.body[0].expression.type !== 'ArrowFunctionExpression' && + ast.body[0].expression.type !== 'FunctionExpression')) { + return false; + } + + return true; + } catch (err) { + return false; + } +} + +function constructJavascriptFunction(data) { + /*jslint evil:true*/ + + var source = '(' + data + ')', + ast = esprima.parse(source, { range: true }), + params = [], + body; + + if (ast.type !== 'Program' || + ast.body.length !== 1 || + ast.body[0].type !== 'ExpressionStatement' || + (ast.body[0].expression.type !== 'ArrowFunctionExpression' && + ast.body[0].expression.type !== 'FunctionExpression')) { + throw new Error('Failed to resolve function'); + } + + ast.body[0].expression.params.forEach(function (param) { + params.push(param.name); + }); + + body = ast.body[0].expression.body.range; + + // Esprima's ranges include the first '{' and the last '}' characters on + // function expressions. So cut them out. + if (ast.body[0].expression.body.type === 'BlockStatement') { + /*eslint-disable no-new-func*/ + return new Function(params, source.slice(body[0] + 1, body[1] - 1)); + } + // ES6 arrow functions can omit the BlockStatement. In that case, just return + // the body. + /*eslint-disable no-new-func*/ + return new Function(params, 'return ' + source.slice(body[0], body[1])); +} + +function representJavascriptFunction(object /*, style*/) { + return object.toString(); +} + +function isFunction(object) { + return Object.prototype.toString.call(object) === '[object Function]'; +} + +module.exports = new Type('tag:yaml.org,2002:js/function', { + kind: 'scalar', + resolve: resolveJavascriptFunction, + construct: constructJavascriptFunction, + predicate: isFunction, + represent: representJavascriptFunction +}); + +},{"../../type":13}],19:[function(require,module,exports){ +'use strict'; + +var Type = require('../../type'); + +function resolveJavascriptRegExp(data) { + if (data === null) return false; + if (data.length === 0) return false; + + var regexp = data, + tail = /\/([gim]*)$/.exec(data), + modifiers = ''; + + // if regexp starts with '/' it can have modifiers and must be properly closed + // `/foo/gim` - modifiers tail can be maximum 3 chars + if (regexp[0] === '/') { + if (tail) modifiers = tail[1]; + + if (modifiers.length > 3) return false; + // if expression starts with /, is should be properly terminated + if (regexp[regexp.length - modifiers.length - 1] !== '/') return false; + } + + return true; +} + +function constructJavascriptRegExp(data) { + var regexp = data, + tail = /\/([gim]*)$/.exec(data), + modifiers = ''; + + // `/foo/gim` - tail can be maximum 4 chars + if (regexp[0] === '/') { + if (tail) modifiers = tail[1]; + regexp = regexp.slice(1, regexp.length - modifiers.length - 1); + } + + return new RegExp(regexp, modifiers); +} + +function representJavascriptRegExp(object /*, style*/) { + var result = '/' + object.source + '/'; + + if (object.global) result += 'g'; + if (object.multiline) result += 'm'; + if (object.ignoreCase) result += 'i'; + + return result; +} + +function isRegExp(object) { + return Object.prototype.toString.call(object) === '[object RegExp]'; +} + +module.exports = new Type('tag:yaml.org,2002:js/regexp', { + kind: 'scalar', + resolve: resolveJavascriptRegExp, + construct: constructJavascriptRegExp, + predicate: isRegExp, + represent: representJavascriptRegExp +}); + +},{"../../type":13}],20:[function(require,module,exports){ +'use strict'; + +var Type = require('../../type'); + +function resolveJavascriptUndefined() { + return true; +} + +function constructJavascriptUndefined() { + /*eslint-disable no-undefined*/ + return undefined; +} + +function representJavascriptUndefined() { + return ''; +} + +function isUndefined(object) { + return typeof object === 'undefined'; +} + +module.exports = new Type('tag:yaml.org,2002:js/undefined', { + kind: 'scalar', + resolve: resolveJavascriptUndefined, + construct: constructJavascriptUndefined, + predicate: isUndefined, + represent: representJavascriptUndefined +}); + +},{"../../type":13}],21:[function(require,module,exports){ +'use strict'; + +var Type = require('../type'); + +module.exports = new Type('tag:yaml.org,2002:map', { + kind: 'mapping', + construct: function (data) { return data !== null ? data : {}; } +}); + +},{"../type":13}],22:[function(require,module,exports){ +'use strict'; + +var Type = require('../type'); + +function resolveYamlMerge(data) { + return data === '<<' || data === null; +} + +module.exports = new Type('tag:yaml.org,2002:merge', { + kind: 'scalar', + resolve: resolveYamlMerge +}); + +},{"../type":13}],23:[function(require,module,exports){ +'use strict'; + +var Type = require('../type'); + +function resolveYamlNull(data) { + if (data === null) return true; + + var max = data.length; + + return (max === 1 && data === '~') || + (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); +} + +function constructYamlNull() { + return null; +} + +function isNull(object) { + return object === null; +} + +module.exports = new Type('tag:yaml.org,2002:null', { + kind: 'scalar', + resolve: resolveYamlNull, + construct: constructYamlNull, + predicate: isNull, + represent: { + canonical: function () { return '~'; }, + lowercase: function () { return 'null'; }, + uppercase: function () { return 'NULL'; }, + camelcase: function () { return 'Null'; } + }, + defaultStyle: 'lowercase' +}); + +},{"../type":13}],24:[function(require,module,exports){ +'use strict'; + +var Type = require('../type'); + +var _hasOwnProperty = Object.prototype.hasOwnProperty; +var _toString = Object.prototype.toString; + +function resolveYamlOmap(data) { + if (data === null) return true; + + var objectKeys = [], index, length, pair, pairKey, pairHasKey, + object = data; + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + pairHasKey = false; + + if (_toString.call(pair) !== '[object Object]') return false; + + for (pairKey in pair) { + if (_hasOwnProperty.call(pair, pairKey)) { + if (!pairHasKey) pairHasKey = true; + else return false; + } + } + + if (!pairHasKey) return false; + + if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); + else return false; + } + + return true; +} + +function constructYamlOmap(data) { + return data !== null ? data : []; +} + +module.exports = new Type('tag:yaml.org,2002:omap', { + kind: 'sequence', + resolve: resolveYamlOmap, + construct: constructYamlOmap +}); + +},{"../type":13}],25:[function(require,module,exports){ +'use strict'; + +var Type = require('../type'); + +var _toString = Object.prototype.toString; + +function resolveYamlPairs(data) { + if (data === null) return true; + + var index, length, pair, keys, result, + object = data; + + result = new Array(object.length); + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + + if (_toString.call(pair) !== '[object Object]') return false; + + keys = Object.keys(pair); + + if (keys.length !== 1) return false; + + result[index] = [ keys[0], pair[keys[0]] ]; + } + + return true; +} + +function constructYamlPairs(data) { + if (data === null) return []; + + var index, length, pair, keys, result, + object = data; + + result = new Array(object.length); + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + + keys = Object.keys(pair); + + result[index] = [ keys[0], pair[keys[0]] ]; + } + + return result; +} + +module.exports = new Type('tag:yaml.org,2002:pairs', { + kind: 'sequence', + resolve: resolveYamlPairs, + construct: constructYamlPairs +}); + +},{"../type":13}],26:[function(require,module,exports){ +'use strict'; + +var Type = require('../type'); + +module.exports = new Type('tag:yaml.org,2002:seq', { + kind: 'sequence', + construct: function (data) { return data !== null ? data : []; } +}); + +},{"../type":13}],27:[function(require,module,exports){ +'use strict'; + +var Type = require('../type'); + +var _hasOwnProperty = Object.prototype.hasOwnProperty; + +function resolveYamlSet(data) { + if (data === null) return true; + + var key, object = data; + + for (key in object) { + if (_hasOwnProperty.call(object, key)) { + if (object[key] !== null) return false; + } + } + + return true; +} + +function constructYamlSet(data) { + return data !== null ? data : {}; +} + +module.exports = new Type('tag:yaml.org,2002:set', { + kind: 'mapping', + resolve: resolveYamlSet, + construct: constructYamlSet +}); + +},{"../type":13}],28:[function(require,module,exports){ +'use strict'; + +var Type = require('../type'); + +module.exports = new Type('tag:yaml.org,2002:str', { + kind: 'scalar', + construct: function (data) { return data !== null ? data : ''; } +}); + +},{"../type":13}],29:[function(require,module,exports){ +'use strict'; + +var Type = require('../type'); + +var YAML_DATE_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9])' + // [2] month + '-([0-9][0-9])$'); // [3] day + +var YAML_TIMESTAMP_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9]?)' + // [2] month + '-([0-9][0-9]?)' + // [3] day + '(?:[Tt]|[ \\t]+)' + // ... + '([0-9][0-9]?)' + // [4] hour + ':([0-9][0-9])' + // [5] minute + ':([0-9][0-9])' + // [6] second + '(?:\\.([0-9]*))?' + // [7] fraction + '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour + '(?::([0-9][0-9]))?))?$'); // [11] tz_minute + +function resolveYamlTimestamp(data) { + if (data === null) return false; + if (YAML_DATE_REGEXP.exec(data) !== null) return true; + if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; + return false; +} + +function constructYamlTimestamp(data) { + var match, year, month, day, hour, minute, second, fraction = 0, + delta = null, tz_hour, tz_minute, date; + + match = YAML_DATE_REGEXP.exec(data); + if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); + + if (match === null) throw new Error('Date resolve error'); + + // match: [1] year [2] month [3] day + + year = +(match[1]); + month = +(match[2]) - 1; // JS month starts with 0 + day = +(match[3]); + + if (!match[4]) { // no hour + return new Date(Date.UTC(year, month, day)); + } + + // match: [4] hour [5] minute [6] second [7] fraction + + hour = +(match[4]); + minute = +(match[5]); + second = +(match[6]); + + if (match[7]) { + fraction = match[7].slice(0, 3); + while (fraction.length < 3) { // milli-seconds + fraction += '0'; + } + fraction = +fraction; + } + + // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute + + if (match[9]) { + tz_hour = +(match[10]); + tz_minute = +(match[11] || 0); + delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds + if (match[9] === '-') delta = -delta; + } + + date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); + + if (delta) date.setTime(date.getTime() - delta); + + return date; +} + +function representYamlTimestamp(object /*, style*/) { + return object.toISOString(); +} + +module.exports = new Type('tag:yaml.org,2002:timestamp', { + kind: 'scalar', + resolve: resolveYamlTimestamp, + construct: constructYamlTimestamp, + instanceOf: Date, + represent: representYamlTimestamp +}); + +},{"../type":13}],"/":[function(require,module,exports){ +'use strict'; + + +var yaml = require('./lib/js-yaml.js'); + + +module.exports = yaml; + +},{"./lib/js-yaml.js":1}]},{},[])("/") +}); diff --git a/.github/.test/samples.json b/.github/.test/samples.json new file mode 100644 index 000000000000..72e76eaa877e --- /dev/null +++ b/.github/.test/samples.json @@ -0,0 +1,1292 @@ +{ + "files": [ + { + "input": "ada-petstore.sh", + "matches": [ + "Client: Ada" + ] + }, + { + "input": "android-petstore-httpclient.sh", + "matches": [ + "Client: Android" + ] + }, + { + "input": "android-petstore-volley.sh", + "matches": [ + "Client: Android" + ] + }, + { + "input": "apache2-petstore-config.sh", + "matches": [ + "Config: Apache" + ] + }, + { + "input": "apex-petstore.sh", + "matches": [ + "Client: Apex" + ] + }, + { + "input": "aspnetcore-petstore-server.sh", + "matches": [ + "Server: C-Sharp" + ] + }, + { + "input": "bash-petstore.sh", + "matches": [ + "Client: Bash" + ] + }, + { + "input": "c-petstore.sh", + "matches": [ + "Client: C" + ] + }, + { + "input": "clojure-petstore.sh", + "matches": [ + "Client: Clojure" + ] + }, + { + "input": "cpp-pistache-server-petstore.sh", + "matches": [ + "Server: C++" + ] + }, + { + "input": "cpp-qt5-petstore.sh", + "matches": [ + "Client: C++", + "Client: QT" + ] + }, + { + "input": "cpp-qt5-qhttpengine-server-petstore.sh", + "matches": [ + "Server: C++" + ] + }, + { + "input": "cpp-restbed-petstore-server.sh", + "matches": [ + "Server: C++" + ] + }, + { + "input": "cpp-restsdk-petstore.sh", + "matches": [ + "Client: C++" + ] + }, + { + "input": "cpp-tizen-petstore.sh", + "matches": [ + "Client: C++" + ] + }, + { + "input": "csharp-dotnet2-petstore.sh", + "matches": [ + "Client: C-Sharp" + ] + }, + { + "input": "csharp-petstore-net-35.sh", + "matches": [ + "Client: C-Sharp" + ] + }, + { + "input": "csharp-petstore-net-40.sh", + "matches": [ + "Client: C-Sharp" + ] + }, + { + "input": "csharp-petstore-net-standard.sh", + "matches": [ + "Client: C-Sharp" + ] + }, + { + "input": "csharp-petstore-netcore-project.sh", + "matches": [ + "Client: C-Sharp" + ] + }, + { + "input": "csharp-petstore.sh", + "matches": [ + "Client: C-Sharp" + ] + }, + { + "input": "csharp-property-changed-petstore.sh", + "matches": [ + "Client: C-Sharp" + ] + }, + { + "input": "csharp-refactor-petstore.sh", + "matches": [ + "Client: C-Sharp" + ] + }, + { + "input": "cwiki-petstore.sh", + "matches": [ + "Documentation: Cwiki" + ] + }, + { + "input": "dart-flutter-petstore.sh", + "matches": [ + "Client: Dart" + ] + }, + { + "input": "dart-jaguar-petstore.sh", + "matches": [ + "Client: Dart" + ] + }, + { + "input": "dart-petstore.sh", + "matches": [ + "Client: Dart" + ] + }, + { + "input": "dart2-petstore.sh", + "matches": [ + "Client: Dart" + ] + }, + { + "input": "dynamic-html.sh", + "matches": [ + "Documentation: Dynamic HTML" + ] + }, + { + "input": "eiffel-petstore.sh", + "matches": [ + "Client: Eiffel" + ] + }, + { + "input": "elixir-petstore.sh", + "matches": [ + "Client: Elixir" + ] + }, + { + "input": "elm-0.18-petstore.sh", + "matches": [ + "Client: Elm" + ] + }, + { + "input": "elm-petstore.sh", + "matches": [ + "Client: Elm" + ] + }, + { + "input": "erlang-petstore-client.sh", + "matches": [ + "Client: Erlang" + ] + }, + { + "input": "erlang-petstore-proper.sh", + "matches": [ + "Client: Erlang" + ] + }, + { + "input": "erlang-petstore-server.sh", + "matches": [ + "Server: Erlang" + ] + }, + { + "input": "finch-petstore-server.sh", + "matches": [ + "Server: Scala" + ] + }, + { + "input": "flash-petstore.sh", + "matches": [ + "Client: Flash/ActionScript" + ] + }, + { + "input": "go-gin-petstore-server.sh", + "matches": [ + "Server: Go" + ] + }, + { + "input": "go-petstore-server.sh", + "matches": [ + "Server: Go" + ] + }, + { + "input": "go-petstore-withxml.sh", + "matches": [ + "Client: Go" + ] + }, + { + "input": "go-petstore.sh", + "matches": [ + "Client: Go" + ] + }, + { + "input": "graphql-schema-petstore.sh", + "matches": [ + "Schema: GraphQL" + ] + }, + { + "input": "graphql-server-petstore.sh", + "matches": [ + "Server: GraphQL" + ] + }, + { + "input": "groovy-petstore.sh", + "matches": [ + "Client: Groovy" + ] + }, + { + "input": "haskell-http-client-petstore.sh", + "matches": [ + "Client: Haskell" + ] + }, + { + "input": "haskell-servant-petstore.sh", + "matches": [ + "Server: Haskell" + ] + }, + { + "input": "html-markdown.sh", + "matches": [ + "Client: HTML" + ] + }, + { + "input": "html-petstore.sh", + "matches": [ + "Client: HTML" + ] + }, + { + "input": "html2-petstore.sh", + "matches": [ + "Client: HTML" + ] + }, + { + "input": "java-inflector-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-msf4j-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-petstore-feign-10x.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-petstore-feign.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-petstore-google-api-client.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-petstore-jersey1.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-petstore-jersey2-java6.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-petstore-jersey2.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-petstore-okhttp-gson-parcelable.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-petstore-okhttp-gson.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-petstore-rest-assured.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-petstore-resteasy.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-petstore-resttemplate-withxml.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-petstore-resttemplate.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-petstore-retrofit.sh", + "matches": [ + "Client: Java", + "Client: Retrofit" + ] + }, + { + "input": "java-petstore-retrofit2-play24.sh", + "matches": [ + "Client: Java", + "Client: Retrofit" + ] + }, + { + "input": "java-petstore-retrofit2-play25.sh", + "matches": [ + "Client: Java", + "Client: Retrofit" + ] + }, + { + "input": "java-petstore-retrofit2-play26.sh", + "matches": [ + "Client: Java", + "Client: Retrofit" + ] + }, + { + "input": "java-petstore-retrofit2.sh", + "matches": [ + "Client: Java", + "Client: Retrofit" + ] + }, + { + "input": "java-petstore-retrofit2rx.sh", + "matches": [ + "Client: Java", + "Client: Retrofit" + ] + }, + { + "input": "java-petstore-retrofit2rx2.sh", + "matches": [ + "Client: Java", + "Client: Retrofit" + ] + }, + { + "input": "java-petstore-vertx.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-petstore-webclient.sh", + "matches": [ + "Client: Java" + ] + }, + { + "input": "java-pkmst-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-play-framework-petstore-server-api-package-override.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-play-framework-petstore-server-async.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-play-framework-petstore-server-controller-only.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-play-framework-petstore-server-fake-endpoints.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-play-framework-petstore-server-no-bean-validation.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-play-framework-petstore-server-no-exception-handling.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-play-framework-petstore-server-no-interface.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-play-framework-petstore-server-no-swagger-ui.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-play-framework-petstore-server-no-wrap-calls.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-play-framework-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-undertow-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-vertx-async-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "java-vertx-rx-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "javascript-closure-angular.sh", + "matches": [ + "Client: JavaScript/Node.js" + ] + }, + { + "input": "javascript-es6-petstore.sh", + "matches": [ + "Client: JavaScript/Node.js" + ] + }, + { + "input": "javascript-flowtyped-petstore.sh", + "matches": [ + "Client: JavaScript/Node.js" + ] + }, + { + "input": "javascript-petstore.sh", + "matches": [ + "Client: JavaScript/Node.js" + ] + }, + { + "input": "javascript-promise-es6-petstore.sh", + "matches": [ + "Client: JavaScript/Node.js" + ] + }, + { + "input": "javascript-promise-petstore.sh", + "matches": [ + "Client: JavaScript/Node.js" + ] + }, + { + "input": "jaxrs-cxf-cdi-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-cxf-client-petstore.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-cxf-petstore-server-annotated-base-path.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-cxf-petstore-server-non-spring-application.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-cxf-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-jersey1-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-jersey1-usetags-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-petstore-server-datelib-j8.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-resteasy-eap-java8-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-resteasy-eap-joda-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-resteasy-eap-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-resteasy-joda-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-resteasy-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-spec-petstore-server-interface-returning-response.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-spec-petstore-server-interface.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-spec-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jaxrs-usetags-petstore-server.sh", + "matches": [ + "Server: Java" + ] + }, + { + "input": "jmeter-petstore.sh", + "matches": [ + "Client: JMeter" + ] + }, + { + "input": "kotlin-client-petstore.sh", + "matches": [ + "Client: Kotlin" + ] + }, + { + "input": "kotlin-client-string.sh", + "matches": [ + "Client: Kotlin" + ] + }, + { + "input": "kotlin-client-threetenbp.sh", + "matches": [ + "Client: Kotlin" + ] + }, + { + "input": "kotlin-server-petstore.sh", + "matches": [ + "Server: Kotlin" + ] + }, + { + "input": "kotlin-springboot-petstore-server.sh", + "matches": [ + "Server: Kotlin" + ] + }, + { + "input": "lua-petstore.sh", + "matches": [ + "Client: Lua" + ] + }, + { + "input": "mysql-schema-petstore.sh", + "matches": [ + "Schema: MySQL" + ] + }, + { + "input": "nancyfx-petstore-server-async.sh", + "matches": [ + "Server: C-Sharp" + ] + }, + { + "input": "nancyfx-petstore-server.sh", + "matches": [ + "Server: C-Sharp" + ] + }, + { + "input": "nodejs-petstore-google-cloud-functions.sh", + "matches": [ + "Server: Nodejs" + ] + }, + { + "input": "nodejs-petstore-server.sh", + "matches": [ + "Server: Nodejs" + ] + }, + { + "input": "objc-petstore-coredata.sh", + "matches": [ + "Client: Objc" + ] + }, + { + "input": "objc-petstore.sh", + "matches": [ + "Client: Objc" + ] + }, + { + "input": "perl-deep-module-petstore.sh", + "matches": [ + "Client: Perl" + ] + }, + { + "input": "perl-petstore.sh", + "matches": [ + "Client: Perl" + ] + }, + { + "input": "php-laravel-petstore-server.sh", + "matches": [ + "Server: PHP" + ] + }, + { + "input": "php-lumen-petstore-server.sh", + "matches": [ + "Server: PHP" + ] + }, + { + "input": "php-petstore.sh", + "matches": [ + "Server: PHP" + ] + }, + { + "input": "php-silex-petstore-server.sh", + "matches": [ + "Server: PHP" + ] + }, + { + "input": "php-slim-server-petstore.sh", + "matches": [ + "Server: PHP" + ] + }, + { + "input": "php-symfony-petstore.sh", + "matches": [ + "Server: PHP" + ] + }, + { + "input": "php-ze-ph-petstore-server.sh", + "matches": [ + "Server: PHP" + ] + }, + { + "input": "powershell-petstore.sh", + "matches": [ + "Client: PowerShell" + ] + }, + { + "input": "python-asyncio-petstore.sh", + "matches": [ + "Client: Python" + ] + }, + { + "input": "python-flask-petstore-python2.sh", + "matches": [ + "Server: Python" + ] + }, + { + "input": "python-flask-petstore.sh", + "matches": [ + "Server: Python" + ] + }, + { + "input": "python-petstore.sh", + "matches": [ + "Client: Python" + ] + }, + { + "input": "python-tornado-petstore.sh", + "matches": [ + "Client: Python" + ] + }, + { + "input": "r-petstore.sh", + "matches": [ + "Client: R" + ] + }, + { + "input": "ruby-client-petstore.sh", + "matches": [ + "Client: Ruby" + ] + }, + { + "input": "ruby-on-rails-server-petstore.sh", + "matches": [ + "Server: Ruby" + ] + }, + { + "input": "ruby-sinatra-server-petstore.sh", + "matches": [ + "Server: Ruby" + ] + }, + { + "input": "rust-petstore.sh", + "matches": [ + "Client: Rust" + ] + }, + { + "input": "rust-reqwest-petstore.sh", + "matches": [ + "Client: Rust" + ] + }, + { + "input": "rust-server-petstore.sh", + "matches": [ + "Server: Rust" + ] + }, + { + "input": "scala-akka-petstore.sh", + "matches": [ + "Client: Scala" + ] + }, + { + "input": "scala-gatling-petstore.sh", + "matches": [ + "Client: Scala" + ] + }, + { + "input": "scala-httpclient-petstore.sh", + "matches": [ + "Client: Scala" + ] + }, + { + "input": "scala-lagom-server-petstore.sh", + "matches": [ + "Server: Scala" + ] + }, + { + "input": "scalatra-petstore-server.sh", + "matches": [ + "Server: Scala" + ] + }, + { + "input": "scalaz-petstore.sh", + "matches": [ + "Client: Scala" + ] + }, + { + "input": "spring-all-pestore.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "spring-cloud-feign-petstore.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "spring-delegate-j8.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "spring-delegate.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "spring-mvc-petstore-j8-async-server.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "spring-mvc-petstore-j8-localdatetime.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "spring-mvc-petstore-server.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "spring-stubs.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "springboot-petstore-server-beanvalidation.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "springboot-petstore-server-implicitHeaders.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "springboot-petstore-server-reactive.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "springboot-petstore-server-useOptional.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "springboot-petstore-server.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "springboot-virtualan-petstore-server.sh", + "matches": [ + "Server: Spring" + ] + }, + { + "input": "swift-petstore-promisekit.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "swift-petstore-rxswift.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "swift-petstore.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "swift3-petstore-objcCompatible.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "swift3-petstore-promisekit.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "swift3-petstore-rxswift.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "swift3-petstore-unwraprequired.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "swift3-petstore.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "swift4-petstore-objcCompatible.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "swift4-petstore-promisekit.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "swift4-petstore-rxswift.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "swift4-petstore-unwrapRequired.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "swift4-petstore.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "swift4-test.sh", + "matches": [ + "Client: Swift" + ] + }, + { + "input": "typescript-angular-v2-petstore-interfaces.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-angular-v2-petstore-with-npm.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-angular-v2-petstore.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-angular-v4-petstore-with-npm.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-angular-v4.3-petstore-with-npm.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-angular-v6-petstore-not-provided-in-root-with-npm.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-angular-v6-petstore-not-provided-in-root.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-angular-v6-petstore-provided-in-root-with-npm.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-angular-v6-petstore-provided-in-root.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-angular-v7-petstore-not-provided-in-root-with-npm.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-angular-v7-petstore-not-provided-in-root.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-angular-v7-petstore-provided-in-root-with-npm.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-angular-v7-petstore-provided-in-root.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-angularjs-petstore.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-aurelia-petstore.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-axios-petstore-interfaces.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-axios-petstore-target-es6.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-axios-petstore-with-npm-version.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-axios-petstore.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-fetch-petstore-interfaces.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-fetch-petstore-target-es6.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-fetch-petstore-with-npm-version.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-fetch-petstore.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-inversify-petstore.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-jquery-petstore-with-npm.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-jquery-petstore.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-node-petstore-with-npm.sh", + "matches": [ + "Client: TypeScript" + ] + }, + { + "input": "typescript-node-petstore.sh", + "matches": [ + "Client: TypeScript" + ] + } + ], + "text": [ + { + "input": "WIP: Example", + "matches": [ + "WIP" + ] + }, + { + "input": "[help wanted] Looking for help", + "matches": [ + "help wanted" + ] + }, + { + "input": "[Announcement] Release 1.0", + "matches": [ + "Announcement" + ] + }, + { + "input": "[announcement] Release 2.0", + "matches": [ + "Announcement" + ] + } + ] +} \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/announcement.md b/.github/ISSUE_TEMPLATE/announcement.md new file mode 100644 index 000000000000..3b3c1d2d9a30 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/announcement.md @@ -0,0 +1,10 @@ +--- +name: Announcement +about: Announcements related to the project +title: "[Announcement] TITLE" +labels: Announcement +assignees: '' + +--- + + diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000000..9de7f88e09af --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,63 @@ +--- +name: Bug report +about: Create a bug report to help us improve +title: "[BUG] Description" +labels: 'Issue: Bug' +assignees: '' + +--- + +#### Bug Report Checklist + +- [ ] Have you provided a full/minimal spec to reproduce the issue? +- [ ] Have you validated the input using an OpenAPI validator ([example](https://apidevtools.org/swagger-parser/online/))? +- [ ] What's the version of OpenAPI Generator used? +- [ ] Have you search for related issues/PRs? +- [ ] What's the actual output vs expected output? +- [ ] [Optional] Bounty to sponsor the fix ([example](https://www.bountysource.com/issues/66123212-javascript-client-produces-a-wrong-object-for-a-string-enum-type-that-is-used-with-ref)) + + + +##### Description + + + +##### openapi-generator version + + + +##### OpenAPI declaration file content or url + + + +##### Command line used for generation + + + +##### Steps to reproduce + + + +##### Related issues/PRs + + + +##### Suggest a fix + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000000..404498fa9a22 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,24 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "[REQ] Feature Request Description" +labels: 'Enhancement: Feature' +assignees: '' + +--- + +### Is your feature request related to a problem? Please describe. + + + +## Describe the solution you'd like + + + +## Describe alternatives you've considered + + + +## Additional context + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index e93ef7163643..e72cc80e885f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,8 @@ ### PR checklist - [ ] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md). -- [ ] Ran the shell script under `./bin/` to update Petstore sample so that CIs can verify the change. (For instance, only need to run `./bin/{LANG}-petstore.sh` and `./bin/security/{LANG}-petstore.sh` if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in `.\bin\windows\`. -- [ ] Filed the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `3.3.x`, `4.0.x`. Default: `master`. +- [ ] Ran the shell script under `./bin/` to update Petstore sample so that CIs can verify the change. (For instance, only need to run `./bin/{LANG}-petstore.sh`, `./bin/openapi3/{LANG}-petstore.sh`, `./bin/security/{LANG}-petstore.sh` and `./bin/openapi3/security/{LANG}-petstore.sh` if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in `.\bin\windows\`. +- [ ] Filed the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`~~, `3.4.x`, `4.0.x`~~. Default: `master`. - [ ] Copied the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) to review the pull request if your PR is targeting a particular programming language. ### Description of the PR diff --git a/.github/auto-labeler.yml b/.github/auto-labeler.yml new file mode 100644 index 000000000000..1cc6d47e68ef --- /dev/null +++ b/.github/auto-labeler.yml @@ -0,0 +1,290 @@ +comment: | + 👍 Thanks for opening this issue! + 🏷 I have applied any labels matching special text in your issue. + + The team will review the labels and make any necessary changes. +labels: + 'Announcement': + - '\s*?\[[Aa]nnouncement\]\s*?' + 'Breaking change (with fallback)': + - '\s*?[bB]reaking [cC]hange [wW]ith [fF]allback\s*?' + 'Breaking change (without fallback)': + - '\s*?[bB]reaking [cC]hange [wW]ithout [fF]allback\s*?' + 'Client: Ada': + - '\s*?\[ada\]\s*?' + - '\s*?-[gl] ada(?!-)\b' + 'Client: Android': + - '\s*?\[android\]\s*?' + - '\s*?-[gl] android(?!-)\b' + 'Client: Apex': + - '\s*?\[apex\]\s*?' + - '\s*?-[gl] apex(?!-)\b' + 'Client: Bash': + - '\s*?\[bash\]\s*?' + - '\s*?-[gl] bash(?!-)\b' + 'Client: C': + - '\s*?\[[cC]\]\s*?' + - '\s*?-[gl] c(?!-)\b' + # 'Client: Ceylon': + 'Client: C++': + - '\s*?\[cpp(-.*)?-client\]\s*?' + - '\s*?-[gl] cpp(-.*)?-client\s*?' + - '\s*?-[gl] cpp-restsdk(?!-)\b' + - '\s*?-[gl] cpp-tizen(?!-)\b' + 'Client: C-Sharp': + - '\s*?-[gl] csharp(?!-)\b' + - '\s*?[cC]-[sS]harp [cC]lient\s*?' + - '\s*?-[gl] csharp-dotnet2\s*?' + - '\s*?-[gl] csharp-refactor?\s*?' + - '\s*?\[[Cc]#\]' + - '\s*?\[csharp\]\s*?' + 'Client: Clojure': + - '\s*?\[clojure\]\s*?' + - '\s*?-[gl] clojure(?!-)\b' + # 'Client: Crystal': + 'Client: Dart': + - '\s*?\[dart\]\s*?' + - '\s*?-[gl] dart(?!-)\b' + 'Client: Dukescript': + - '\s*?\[dukescript\]\s*?' + - '\s*?-g dukescript\s*?' + 'Client: Eiffel': + - '\s*?\[eiffel\]\s*?' + - '\s*?-[gl] eiffel(?!-)\b' + 'Client: Elixir': + - '\s*?\[elixir\]\s*?' + - '\s*?-[gl] elixir(?!-)\b' + 'Client: Elm': + - '\s*?\[elm\]\s*?' + - '\s*?-[gl] elm(?!-)\b' + 'Client: Erlang': + - '\s*?\[erlang(-.*)?-client\]\s*?' + - '\s*?-[gl] erlang(-.*)?-client\s*?' + - '\s*?\[erlang-proper\]\s*?' + - '\s*?-[gl] erlang-proper\s*?' + 'Client: Flash/ActionScript': + - '\s*?\[flash\]\s*?' + - '\s*?-[gl] flash(?!-)\b' + 'Client: Go': + - '\s*?\[go\]\s*?' + - '\s*?-[gl] go(?!-)\b' + 'Client: Groovy': + - '\s*?\[groovy\]\s*?' + - '\s*?-[gl] groovy(?!-)\b' + 'Client: HTML': + - '\s*?\[html[2]?\]\s*?' + - '\s*?-[gl] html[2]?\s*?' + 'Client: Haskell': + - '\s*?\[haskell(-.*)?-client\]\s*?' + - '\s*?-[gl] haskell(-.*)?-client\s*?' + 'Client: JMeter': + - '\s*?\[jmeter\]\s*?' + - '\s*?-[gl] jmeter\s*?' + 'Client: Java': + - '\s*?\[java\]\s*?' + - '\s*?-[gl] java(?!-)\b' + 'Client: JavaScript/Node.js': + - '\s*?\[javascript\]\s*?' + - '\s*?-[gl] javascript\s*?' + - '\s*?-[gl] javascript-(\S)*\s*?' + # 'Client: Julia': # NOTE: Not yet implemented + 'Client: Kotlin': + - '\s*?\[kotlin\]\s*?' + - '\s*?-[gl] kotlin(?!-)\b' + 'Client: Lisp': + - '\s*?\[lisp\]\s*?' + - '\s*?-[gl] lisp(?!-)\b' + 'Client: Lua': + - '\s*?\[lua\]\s*?' + - '\s*?-[gl] lua(?!-)\b' + 'Client: Objc': + - '\s*?\[objc\]\s*?' + - '\s*?-[gl] objc\s*?' + # 'Client: OCaml': + 'Client: Perl': + - '\s*?\[perl\]\s*?' + - '\s*?-[gl] perl(?!-)\b' + # 'Client: PHP': + 'Client: PowerShell': + - '\s*?\[powershell\]\s*?' + - '\s*?-[gl] powershell\s*?' + 'Client: Python': + - '\s*?\[python\]\s*?' + - '\s*?-[gl] python(?!-)\b' + 'Client: QT': + - '\s*?\[cpp-qt5-client\]\s*?' + - '\s*?-[gl] cpp-qt5-client\s*?' + 'Client: R': + - '\s*?\[[rR]\]\s*?' + - '\s*?-[gl] r(?!-)\b' + 'Client: Reason ML': + - '\s*?\[reasonml\]\s*?' + - '\s*?-[g] reasonml\s*?' + 'Client: Retrofit': + - '\s*?retrofit.*?\s*?' + 'Client: Ruby': + - '\s*?\[ruby\]\s*?' + - '\s*?-[gl] ruby(?!-)\b' + 'Client: Rust': + - '\s*?\[rust\]\s*?' + - '\s*?-[gl] rust(?!-)\b' + 'Client: Scala': + - '\s*?\[scalaz\]\s*?' + - '\s*?-[gl] scalaz\s*?' + - '\s*?\[scala-(?!finch)[a-z]+\]\b' + - '\s*?-[gl] scala-(?!finch)[a-z]+?(?!-)\b' + 'Client: Swift': + - '\s*?\[swift[34]+\]\s*?' + - '\s*?-[gl] swift[34]+\s*?' + - '\s*?-[gl] swift2-deprecated\s*?' + 'Client: TypeScript': + - '\s*?\[typescript-[\-a-z]+\]\s*?' + - '\s*?-[gl] typescript-[\-a-z]+\s*?' + # 'Client: VB/VB.net': # NOTE: Not yet implemented + # 'Client: Visual Basic': # TODO: REMOVE UNUSED LABEL + 'Config: Apache': + - '\s*?\[apache2\]\s*?' + - '\s*?-[gl] apache2\s*?' + 'Docker': + - '\s*?\[docker\]\s*?' + 'Documentation: Cwiki': + - '\s*?\[cwiki\]\s*?' + - '\s*?-[gl] cwiki\s*?' + 'Documentation: Dynamic HTML': + - '\s*?\[dynamic-html\]\s*?' + - '\s*?-[gl] dynamic-html\s*?' + 'Enhancement: CI/Test': + - '\s*?\[ci\]\s*?' + 'Enhancement: Code format': + - '\s*?\[format(ting)?\]\s*?' + # 'Enhancement: Compatibility': + 'Enhancement: Feature': + - '\s*?\[feat(ure)?s*?' + 'Enhancement: General': + - '\s*?\[general\]\s*?' + - '\s*?\[core\]\s*?' + # 'Enhancement: New generator': + 'Enhancement: Performance': + - '\s*?\[perf\]\s*?' + # 'Feature List: API clients': + # 'Feature List: API documentations': + # 'Feature List: API servers': + # 'Feature: Authentication': + # 'Feature: Composition / Inheritance': + # 'Feature: Documentation': + # 'Feature: Enum': + # 'Feature: Generator': + 'Feature: OAS 3.0 spec support': + - '\s*?\[oas3[\.0]?\]\s*?' + # 'General: Awaiting feedback': + 'General: Discussion': + - '\s*?\[discussion\]\s*?' + 'General: Question': + - '\s*?\[question\]\s*?' + 'General: Suggestion': + - '\s*?\[suggestion\]\s*?' + 'General: Support': + - '\s*?\[support\]\s*?' + 'Issue: Bug': + - '\s*?\[bug(s)?\]\s*?' + - '\s*?\[fix(es)?\]\s*?' + # 'Issue: Invalid spec': + # 'Issue: Migration': + # 'Issue: Non-operational': + # 'Issue: Platform': + # 'Issue: Regression': + 'Issue: Security': + - '\s*?\[security\]\s*?' + # 'Issue: Unable to reproduce': + # 'Issue: Undo changes': + # 'Issue: Usage/Installation': + # 'Issue: Workaround available': + 'OpenAPI Generator CLI': + - '\s*?\[cli\]\s*?' + 'OpenAPI Generator Gradle Plugin': + - '\s*?\[gradle\]\s*?' + 'OpenAPI Generator Maven Plugin': + - '\s*?\[maven\]\s*?' + 'OpenAPI Generator Online': + - '\s*?\[online\]\s*?' + 'Schema: MySQL': + - '\s*?\[mysql\]\s*?' + - '\s*?-[gl] mysql\s*?' + 'Schema: GraphQL': + - '\s*?\[graphql-schema\]\s*?' + - '\s*?-[gl] graphql-schema\s*?' + 'Server: Ada': + - '\s*?\[ada(-.*)?-server\]\s*?' + - '\s*?-[gl] ada(-.*)?-server\s*?' + 'Server: C++': + - '\s*?\[cpp(-.*)?-server\]\s*?' + - '\s*?-[gl] cpp(-.*)?-server\s*?' + 'Server: C-Sharp': + - '\s*?\[aspnetcore\]\s*?' + - '\s*?-[gl] aspnetcore\s*?' + - '\s*?\[csharp-nancyfx\]\s*?' + - '\s*?-[gl] csharp-nancyfx\s*?' + # 'Server: Ceylon': # TODO: REMOVE UNUSED LABEL + 'Server: Eiffel': + - '\s*?\[eiffel(-.*)?-server\]\s*?' + - '\s*?-[gl] eiffel(-.*)?-server\s*?' + 'Server: Elixir': + - '\s*?\[elixir(-.*)?-server\]\s*?' + - '\s*?-[gl] elixir(-.*)?-server\s*?' + 'Server: Erlang': + - '\s*?\[erlang-server\]\s*?' + - '\s*?-[gl] erlang-server\s*?' + 'Server: Go': + - '\s*?\[go(-.*)?-server\]\s*?' + - '\s*?-[gl] go(-.*)?-server\s*?' + 'Server: GraphQL': + - '\s*?\[graphql(-.*)?-server\]\s*?' + - '\s*?-[gl] graphql(-.*)?-server\s*?' + 'Server: Haskell': + - '\s*?\[haskell]\s*?' + - '\s*?-[gl] haskell(?!-)\b' + 'Server: Java': + - '\s*?\[java-.*?\]\s*?' + - '\s*?-[gl] java-.*?\s*?' + - '\s*?-[gl] jaxrx-.*?\s*?' + 'Server: Kotlin': + - '\s*?\[ktor]\s*?' + - '\s*?\[kotlin-spring]\s*?' + - '\s*?\[kotlin(-.*)?-server\]\s*?' + - '\s*?-[gl] kotlin(-.*)?-server\s*?' + - '\s*?-[gl] kotlin-spring\s*?' + 'Server: Nodejs': + - '\s*?\[nodejs(-.*)?-server\]\s*?' + - '\s*?-[gl] nodejs(-.*)?-server\s*?' + 'Server: PHP': + - '\s*?\[php-.*?\]\s*?' + - '\s*?-[gl] php-.*?\s*?' + 'Server: Perl': + - '\s*?\[perl(-.*)?-server\]\s*?' + - '\s*?-g perl(-.*)?-server\s*?' + 'Server: Python': + - '\s*?\[python-.*?\]\s*?' + - '\s*?-[gl] python-.*?\s*?' + 'Server: Ruby': + - '\s*?\[ruby-.*?\]\s*?' + - '\s*?-[gl] ruby-.*?\s*?' + 'Server: Rust': + - '\s*?\[rust(-.*)?-server\]\s*?' + - '\s*?-[gl] rust(-.*)?-server\s*?' + 'Server: Scala': + - '\s*?\[scala(-.*)?-server\]\s*?' + - '\s*?-[gl] scala(-.*)?-server\s*?' + - '\s*?\[scalatra\]\s*?' + - '\s*?-[gl] scalatra\s*?' + - '\s*?\[scala-finch\]\s*?' + - '\s*?-[gl] scala-finch\s*?' + 'Server: Spring': + - '\s*?\[spring\]\s*?' + - '\s*?-[g] spring\s*?' + # 'Swagger-Parser': + 'WIP': + - '\s*?\[wip\]\s*?' + - '\s*?\[WIP\]\s*?' + - '\bWIP:.*?' + 'help wanted': + - '\s*?\[help wanted\]\s*?' diff --git a/.gitignore b/.gitignore index fd191d361953..284e3e95f54b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ out/ *.gpg classpath.txt version.properties +modules/openapi-generator-gradle-plugin/bin/ !modules/openapi-generator-cli/src/main/resources/version.properties .project .classpath @@ -26,6 +27,7 @@ packages/ .packages .vagrant/ .vscode/ +**/.vs .settings @@ -93,21 +95,6 @@ samples/client/petstore/java/jersey2-java6/project/ samples/client/petstore/java/jersey2-java8/project/ samples/client/petstore/java/jersey2/project/ -#PHP -samples/client/petstore/php/OpenAPIToolsClient-php/composer.lock -samples/client/petstore/php/OpenAPIToolsClient-php/vendor/ -samples/client/petstore/silex/SwaggerServer/composer.lock -samples/client/petstore/silex/SwaggerServer/venodr/ -**/vendor/ -**/composer.lock - -#PHP-Symfony -samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/cache/ -samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/logs/ - -#PHP-laravel -samples/server/petstore/php-laravel/node_modules - # Perl samples/client/petstore/perl/deep_module_test/ @@ -130,19 +117,18 @@ samples/client/petstore/swift/**/SwaggerClientTests/SwaggerClient.xcworkspace/xc samples/client/petstore/swift/**/SwaggerClientTests/Pods/ #samples/client/petstore/swift/**/SwaggerClientTests/Pods/Pods.xcodeproj/xcuserdata #samples/client/petstore/swift/**/SwaggerClientTests/Pods/Pods.xcodeproj/xcshareddata/xcschemes -samples/client/petstore/swift/**/SwaggerClientTests/Podfile.lock +samples/client/petstore/swift/**/SwaggerClientTests/Podfile.lock # Swift3 samples/client/petstore/swift3/**/SwaggerClientTests/SwaggerClient.xcodeproj/xcuserdata samples/client/petstore/swift3/**/SwaggerClientTests/SwaggerClient.xcworkspace/xcuserdata #samples/client/petstore/swift3/**/SwaggerClientTests/Pods/ #samples/client/petstore/swift3/**/SwaggerClientTests/Pods/Pods.xcodeproj/xcuserdata #samples/client/petstore/swift3/**/SwaggerClientTests/Pods/Pods.xcodeproj/xcshareddata/xcschemes -samples/client/petstore/swift3/**/SwaggerClientTests/Podfile.lock +samples/client/petstore/swift3/**/SwaggerClientTests/Podfile.lock # C# *.csproj.user samples/client/petstore/csharp/SwaggerClient/IO.Swagger.userprefs -samples/client/petstore/csharp/SwaggerClientTest/.vs samples/client/petstore/csharp/SwaggerClientTest/obj samples/client/petstore/csharp/SwaggerClientTest/bin samples/client/petstore/csharp/SwaggerClientTest/packages @@ -160,6 +146,8 @@ samples/client/petstore/csharp/SwaggerClient/bin/Debug/ samples/client/petstore/csharp/SwaggerClient/packages samples/client/petstore/csharp/SwaggerClient/TestResult.xml samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/IO.Swagger.userprefs +samples/client/petstore/csharp-refactor/OpenAPIClient/TestResult.xml +samples/client/petstore/csharp-refactor/OpenAPIClient/nuget.exe # Python *.pyc @@ -192,15 +180,21 @@ samples/client/petstore/kotlin/src/main/kotlin/test/ samples/client/petstore/kotlin-threetenbp/build samples/client/petstore/kotlin-string/build samples/server/petstore/kotlin-server/ktor/build +samples/openapi3/client/petstore/kotlin/build \? # haskell .stack-work .cabal-sandbox cabal.project.local +samples/client/petstore/haskell-http-client/docs/haddock-bundle.min.js +samples/client/petstore/haskell-http-client/docs/meta.json +samples/client/petstore/haskell-http-client/docs/quick-jump.css # R .Rproj.user +samples/client/petstore/R/**/petstore.Rcheck/ +samples/client/petstore/R/**/*.tar.gz # elixir samples/client/petstore/elixir/_build/ @@ -213,6 +207,8 @@ samples/client/petstore/groovy/build # erlang samples/client/petstore/erlang-client/_build/ samples/client/petstore/erlang-client/rebar.lock +samples/client/petstore/erlang-proper/_build/ +samples/client/petstore/erlang-proper/rebar.lock samples/server/petstore/erlang-server/_build/ samples/server/petstore/erlang-server/rebar.lock @@ -226,3 +222,7 @@ samples/client/petstore/javascript/package-lock.json # elm samples/client/petstore/elm/index.html + +# C +samples/client/petstore/c/build +samples/client/petstore/c/*.so diff --git a/.hub.cli.dockerfile b/.hub.cli.dockerfile new file mode 100644 index 000000000000..a3686f52ee37 --- /dev/null +++ b/.hub.cli.dockerfile @@ -0,0 +1,36 @@ +## The builder labeled image acts as a transient container which is meant to +## hold all non-artifact code. +## +## You can build _just_ this part with: +## docker --target builder -t container-name:builder -f .hub.cli.dockerfile . +FROM jimschubert/8-jdk-alpine-mvn:1.0 as builder + +RUN set -x && \ + apk add --no-cache bash + +ENV GEN_DIR /opt/openapi-generator +WORKDIR ${GEN_DIR} +COPY . ${GEN_DIR} + +# Pre-compile openapi-generator-cli +RUN mvn -am -pl "modules/openapi-generator-cli" package + +## The final (release) image +## The resulting container here only needs the target jar +## and ca-certificates (to be able to query HTTPS hosted specs) +FROM openjdk:8-jre-alpine + +ENV GEN_DIR /opt/openapi-generator + +RUN apk --no-cache add ca-certificates bash +RUN mkdir -p ${GEN_DIR}/modules/openapi-generator-cli/target + +WORKDIR ${GEN_DIR}/modules/openapi-generator-cli/target + +COPY --from=builder ${GEN_DIR}/modules/openapi-generator-cli/target/openapi-generator-cli.jar ${GEN_DIR}/modules/openapi-generator-cli/target/openapi-generator-cli.jar + +COPY docker-entrypoint.sh /usr/local/bin/ + +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD ["help"] diff --git a/.hub.online.dockerfile b/.hub.online.dockerfile new file mode 100644 index 000000000000..083b84d4ead2 --- /dev/null +++ b/.hub.online.dockerfile @@ -0,0 +1,35 @@ +## The builder labeled image acts as a transient container which is meant to +## hold all non-artifact code. +## +## You can build _just_ this part with: +## docker --target builder -t container-name:builder -f .hub.online.dockerfile . +FROM jimschubert/8-jdk-alpine-mvn:1.0 as builder + +RUN set -x && \ + apk add --no-cache bash + +ENV GEN_DIR /opt/openapi-generator +WORKDIR ${GEN_DIR} +COPY . ${GEN_DIR} + +# Pre-compile openapi-generator-online +RUN mvn -am -pl "modules/openapi-generator-online" package + +## The final (release) image +## The resulting container here only needs the target jar +FROM openjdk:8-jre-alpine + +ENV GEN_DIR /opt/openapi-generator +ENV TARGET_DIR /generator + +RUN mkdir -p ${TARGET_DIR} + +WORKDIR ${TARGET_DIR} + +COPY --from=builder ${GEN_DIR}/modules/openapi-generator-online/target/openapi-generator-online.jar ${TARGET_DIR}/openapi-generator-online.jar + +ENV GENERATOR_HOST=http://localhost + +EXPOSE 8080 + +CMD ["java", "-jar", "/generator/openapi-generator-online.jar"] diff --git a/.travis.yml b/.travis.yml index 159d08b7a1c1..a1b712149fdd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: java jdk: - openjdk8 - cache: directories: - $HOME/.m2 @@ -29,8 +28,11 @@ cache: - $HOME/samples/server/petstore/rust-server/target - $HOME/perl5 - $HOME/.cargo - - $HOME/.stack + - $HOME/.pub-cache - $HOME/samples/server/petstore/cpp-pistache/pistache + - $HOME/.npm + - $HOME/.rvm/gems/ruby-2.4.1 + - $HOME/website/node_modules/ services: - docker @@ -47,17 +49,13 @@ addons: - petstore.swagger.io before_install: - # install haskell - - curl -sSL https://get.haskellstack.org/ | sh - - stack upgrade - - stack --version # install rust - curl https://sh.rustup.rs -sSf | sh -s -- -y -v # required when sudo: required for the Ruby petstore tests - gem install bundler - npm install -g typescript - npm install -g npm - - npm install -g elm + - npm install -g elm@0.18.0-exp5 - npm config set registry http://registry.npmjs.org/ # set python 3.6.3 as default - source ~/virtualenv/python3.6/bin/activate @@ -66,10 +64,20 @@ before_install: - docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore - docker ps -a # Add bats test framework and cURL for Bash script integration tests - - sudo add-apt-repository ppa:duggan/bats --yes - - sudo apt-get update -qq - - sudo apt-get install -qq bats - - sudo apt-get install -qq curl + #- sudo add-apt-repository ppa:duggan/bats --yes + #- sudo apt-get update -qq + #- sudo apt-get install -qq bats + #- sudo apt-get install -qq curl + # install dart + #- sudo apt-get update + #- sudo apt-get install apt-transport-https + #- sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -' + #- sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list' + #- sudo apt-get update + #- sudo apt-get install dart + # switch to php7 + - phpenv global 7.1 + - php -v # install perl module #- cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib) #- cpanm Test::Exception Test::More Log::Any LWP::UserAgent JSON URI:Query Module::Runtime DateTime Module::Find Moose::Role @@ -89,16 +97,19 @@ before_install: gpg --keyserver keyserver.ubuntu.com --recv-key $SIGNING_KEY ; gpg --check-trustdb ; fi; + - pushd .; cd website; npm install; popd install: # Add Godeps dependencies to GOPATH and PATH #- eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.4 bash)" #- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace" - - export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$HOME/.cargo/bin:$PATH" + - export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$HOME/.cargo/bin:$PATH:/usr/lib/dart/bin" #- go version - gcc -v - echo $CC - echo $CXX + #- pub version + #- dart --version script: # fail fast @@ -110,8 +121,8 @@ script: # fail if generators contain tab '\t' - /bin/bash ./bin/utils/detect_tab_in_java_class.sh # run integration tests defined in maven pom.xml - - mvn --quiet clean install - - mvn --quiet verify -Psamples + - ./run-in-docker.sh mvn --quiet --batch-mode clean install + - mvn --quiet --batch-mode verify -Psamples after_success: # push to maven repo - if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then @@ -123,7 +134,7 @@ after_success: ./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon; echo "Finished ./gradlew uploadArchives"; popd; - elif ([ "$TRAVIS_BRANCH" == "4.0.x" ]) ; then + elif ([[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]) ; then mvn clean deploy --settings CI/settings.xml; echo "Finished mvn clean deploy for $TRAVIS_BRANCH"; pushd .; @@ -136,7 +147,16 @@ after_success: ## docker: build and push openapi-generator-online to DockerHub - if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && docker build -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/openapi-generator-online && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME && echo "Pushed to $DOCKER_GENERATOR_IMAGE_NAME"; fi; fi ## docker: build cli image and push to Docker Hub - - if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME && echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME"; fi; fi + - if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && cp docker-entrypoint.sh ./modules/openapi-generator-cli && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME && echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME"; fi; fi + ## publish latest website, variables below are secure environment variables which are unavailable to PRs from forks. + - if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + cd website; + git config --global user.name "${GH_NAME}"; + git config --global user.email "${GH_EMAIL}"; + echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc; + npm install; + GIT_USER="${GH_NAME}" npm run-script publish-gh-pages; + fi; env: - DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test CC=gcc-5 CXX=g++-5 diff --git a/CI/circle_parallel.sh b/CI/circle_parallel.sh index 3487a09bf6ef..d9df86eae428 100755 --- a/CI/circle_parallel.sh +++ b/CI/circle_parallel.sh @@ -1,19 +1,38 @@ #!/bin/bash +# +# A bash script to run CircleCI node/test in parallel +# NODE_INDEX=${CIRCLE_NODE_INDEX:-0} +set -e if [ "$NODE_INDEX" = "1" ]; then - echo "Running node $NODE_INDEX to test CI/pom.xml.circleci ..." - cp CI/pom.xml.circleci pom.xml + echo "Running node $NODE_INDEX to test 'samples.circleci' defined in pom.xml ..." + #cp CI/pom.xml.circleci pom.xml java -version - mvn --quiet verify -Psamples + mvn --quiet verify -Psamples.circleci +elif [ "$NODE_INDEX" = "2" ]; then + # run ensure-up-to-date sample script on SNAPSHOT version only + project_version=`mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout` + if [[ $project_version == *"-SNAPSHOT" ]]; then + echo "Running node $NODE_INDEX to test ensure-up-to-date" + java -version + ./bin/utils/ensure-up-to-date + fi +elif [ "$NODE_INDEX" = "3" ]; then + echo "Running node $NODE_INDEX to test haskell" + # install haskell + url -sSL https://get.haskellstack.org/ | sh + stack upgrade + stack --version:w + mvn --quiet verify -Psamples.misc else - echo "Running node $NODE_INDEX to test CI/pom.xml.circleci.java7 ..." + echo "Running node $NODE_INDEX to test 'samples.circleci.jdk7' defined in pom.xml ..." sudo update-java-alternatives -s java-1.7.0-openjdk-amd64 java -version - cp CI/pom.xml.circleci.java7 pom.xml - mvn --quiet verify -Psamples + #cp CI/pom.xml.circleci.java7 pom.xml + mvn --quiet verify -Psamples.circleci.jdk7 fi diff --git a/CI/pom.xml.bash b/CI/pom.xml.bash deleted file mode 100644 index 79cbb5fe12c9..000000000000 --- a/CI/pom.xml.bash +++ /dev/null @@ -1,943 +0,0 @@ - - - org.sonatype.oss - oss-parent - 5 - - 4.0.0 - org.openapitools - openapi-generator-project - pom - openapi-generator-project - 4.0.0-SNAPSHOT - https://github.com/openapi-tools/openapi-generator - - scm:git:git@github.com:openapi-tools/openapi-generator.git - scm:git:git@github.com:openapi-tools/openapi-generator.git - https://github.com/openapi-tools/openapi-generator - - - - - fehguy - Tony Tam - fehguy@gmail.com - - - - wing328 - William Cheng - wing328hk@gmail.com - - - jimschubert - Jim Schubert - james.schubert@gmail.com - - - cbornet - Christophe Bornet - - - jaz-ah - Joseph Zuromski - - - ackintosh - Akihito Nakano - - - JFCote - Jean-François Côté - - - jmini - Jérémie Bresson - dev@jmini.fr - - - - github - https://github.com/openapi-tools/openapi-generator/issues - - - - Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0.html - repo - - - - src/main/java - target/classes - - - org.jvnet.wagon-svn - wagon-svn - 1.8 - - - org.apache.maven.wagon - wagon-ssh-external - 1.0-alpha-6 - - - org.apache.maven.wagon - wagon-webdav - 1.0-beta-1 - - - install - target - ${project.artifactId}-${project.version} - - - net.revelc.code - formatter-maven-plugin - - - - 1.8 - 1.8 - 1.8 - LF - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire-version} - - none:none - -XX:+StartAttachListener - - - - test-testng - test - - test - - - none:none - org.testng:testng - - - - - - maven-dependency-plugin - - - package - - copy-dependencies - - - ${project.build.directory}/lib - - - - - - maven-compiler-plugin - 3.6.1 - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - - development - ${project.url} - ${project.version} - org.openapi-tools - - - - - - org.apache.maven.plugins - maven-site-plugin - 3.5.1 - - - org.apache.maven.plugins - maven-release-plugin - 2.5.3 - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.0.1 - - true - 1.8 - UTF-8 - 1g - true - ${javadoc.package.exclude} - - - - attach-javadocs - verify - - jar - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.0.1 - - - attach-sources - verify - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - 1.4.1 - - - enforce-versions - - enforce - - - - - 3.2.5 - - - - - - - - - - - net.revelc.code - formatter-maven-plugin - 0.5.2 - - - - - - - release-profile - - true - - - - - net.alchim31.maven - scala-maven-plugin - - - - compile - testCompile - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - prepare-package - - add-source - - - - src/main/scala - - - - - - - - - - release-sign-artifacts - - - performRelease - true - - - - - - org.apache.maven.plugins - maven-gpg-plugin - - - sign-artifacts - verify - - sign - - - - - - - - - - android-client - - - env - java - - - - samples/client/petstore/android/volley - - - - bash-client - - - env - java - - - - samples/client/petstore/bash - - - - clojure-client - - - env - clojure - - - - samples/client/petstore/clojure - - - - haskell-http-client - - - env - haskell-http-client - - - - samples/client/petstore/haskell-http-client - - - - haskell-http-client-integration-test - - - env - haskell-http-client - - - - samples/client/petstore/haskell-http-client/tests-integration - - - - java-client-jersey1 - - - env - java - - - - samples/client/petstore/java/jersey1 - - - - java-client-jersey2 - - - env - java - - - - samples/client/petstore/java/jersey2 - - - - java-client-jersey2-java6 - - - env - java - - - - samples/client/petstore/java/jersey2-java6 - - - - java-client-okhttp-gson - - - env - java - - - - samples/client/petstore/java/okhttp-gson - - - - java-client-okhttp-gson-parcelable - - - env - java - - - - samples/client/petstore/java/okhttp-gson/parcelableModel - - - - java-client-retrofit - - - env - java - - - - samples/client/petstore/java/retrofit - - - - java-client-retrofit2 - - - env - java - - - - samples/client/petstore/java/retrofit2 - - - - java-client-retrofit2-rx - - - env - java - - - - samples/client/petstore/java/retrofit2rx - - - - java-client-feign - - - env - java - - - - samples/client/petstore/java/feign - - - - javascript-client - - - env - javascript - - - - samples/client/petstore/javascript - - - - scala-client - - - env - scala - - - - samples/client/petstore/scala - - - - java-msf4j-server - - - env - java - - - - samples/server/petstore/java-msf4/ - - - - jaxrs-cxf-server - - - env - java - - - - samples/server/petstore/jaxrs-cxf - - - - jaxrs-resteasy-server - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/default - - - - jaxrs-resteasy-server-joda - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/joda - - - - jaxrs-resteasy-eap-server - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/eap - - - - jaxrs-resteasy-eap-server-joda - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/eap-joda - - - - jaxrs-server - - - env - java - - - - samples/server/petstore/jaxrs/jersey2 - - - - jaxrs-server-jersey1 - - - env - java - - - - samples/server/petstore/jaxrs/jersey1 - - - - typescript-fetch-client-tests-default - - - env - java - - - - samples/client/petstore/typescript-fetch/tests/default - - - - typescript-fetch-client-builds-default - - - env - java - - - - samples/client/petstore/typescript-fetch/builds/default - - - - typescript-fetch-client-builds-es6-target - - - env - java - - - - samples/client/petstore/typescript-fetch/builds/es6-target - - - - typescript-fetch-client-builds-with-npm-version - - - env - java - - - - samples/client/petstore/typescript-fetch/builds/with-npm-version - - - - typescript-angularjs-client - - - env - java - - - - samples/client/petstore/typescript-angularjs/npm - - - - typescript-node-npm-client - - - env - java - - - - samples/client/petstore/typescript-node/npm - - - - python-client - - - env - java - - - - samples/client/petstore/python - - - - ruby-client - - - env - java - - - - samples/client/petstore/ruby - - - - go-client - - - env - java - - - - samples/client/petstore/go - - - - spring-mvc - - - env - java - - - - samples/server/petstore/spring-mvc - - - - springboot-beanvalidation - - - env - java - - - - samples/server/petstore/springboot-beanvalidation - - - - springboot-reactive - - - env - java - - - - samples/server/petstore/springboot-reactive - - - - springboot - - - env - java - - - - samples/server/petstore/springboot - - - - spring-cloud - - - env - java - - - - samples/client/petstore/spring-cloud - - - - scalatra-server - - - env - java - - - - samples/server/petstore/scalatra - - - - java-inflector - - - env - java - - - - samples/server/petstore/java-inflector - - - - java-undertowr - - - env - java - - - - samples/server/petstore/undertow - - - - samples - - - env - samples - - - - samples/client/petstore/bash - - - - - modules/openapi-generator - modules/openapi-generator-cli - modules/openapi-generator-maven-plugin - modules/openapi-generator-online - - - target/site - - - net.alchim31.maven - scala-maven-plugin - ${scala-maven-plugin-version} - - - org.apache.maven.plugins - maven-jxr-plugin - 2.5 - - true - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.9 - - - - project-team - - - - - - - - - - junit - junit - ${junit-version} - test - - - org.testng - testng - ${testng-version} - test - - - org.jmockit - jmockit - ${jmockit-version} - test - - - - - - sonatype-snapshots - https://oss.sonatype.org/content/repositories/snapshots - - true - - - - - 2.0.2-OpenAPITools.org-1 - 2.0.1 - 2.11.1 - 3.3.0 - 2.4 - 1.2 - 4.8.1 - 2.8.9 - 1.0.0 - 3.4 - 1.7.12 - 3.2.1 - 1.14 - 4.1.0 - 6.9.6 - 2.19.1 - 1.25 - 0.9.10 - 2.0.2.RELEASE - - diff --git a/CI/pom.xml.circleci b/CI/pom.xml.circleci deleted file mode 100644 index 5009b6880304..000000000000 --- a/CI/pom.xml.circleci +++ /dev/null @@ -1,1051 +0,0 @@ - - - - org.sonatype.oss - oss-parent - 5 - - 4.0.0 - org.openapitools - openapi-generator-project - pom - openapi-generator-project - 4.0.0-SNAPSHOT - https://github.com/openapitools/openapi-generator - - scm:git:git@github.com:openapitools/openapi-generator.git - scm:git:git@github.com:openapitools/openapi-generator.git - https://github.com/openapitools/openapi-generator - - - 2.2.0 - - - - - fehguy - Tony Tam - fehguy@gmail.com - - - - wing328 - William Cheng - wing328hk@gmail.com - - - jimschubert - Jim Schubert - james.schubert@gmail.com - - - cbornet - Christophe Bornet - - - jaz-ah - Joseph Zuromski - - - ackintosh - Akihito Nakano - - - JFCote - Jean-François Côté - - - jmini - Jérémie Bresson - dev@jmini.fr - - - - github - https://github.com/openapitools/openapi-generator/issues - - - - Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0.html - repo - - - - src/main/java - target/classes - - - org.jvnet.wagon-svn - wagon-svn - 1.8 - - - org.apache.maven.wagon - wagon-ssh-external - 1.0-alpha-6 - - - org.apache.maven.wagon - wagon-webdav - 1.0-beta-1 - - - install - target - ${project.artifactId}-${project.version} - - - net.revelc.code - formatter-maven-plugin - - - - 1.8 - 1.8 - 1.8 - LF - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire-version} - - none:none - -XX:+StartAttachListener - - - - test-testng - test - - test - - - none:none - org.testng:testng - - - - - - maven-dependency-plugin - - - package - - copy-dependencies - - - ${project.build.directory}/lib - - - - - - maven-compiler-plugin - 3.6.1 - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - - development - ${project.url} - ${project.version} - org.openapitools - - - - - - org.apache.maven.plugins - maven-site-plugin - 3.5.1 - - - org.apache.maven.plugins - maven-release-plugin - 2.5.3 - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.0.1 - - true - 1.8 - UTF-8 - 1g - true - ${javadoc.package.exclude} - - - - attach-javadocs - verify - - jar - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.0.1 - - - attach-sources - verify - - jar-no-fork - - - - - - - - - net.revelc.code - formatter-maven-plugin - 0.5.2 - - - - - - - release-profile - - true - - - - - net.alchim31.maven - scala-maven-plugin - - - - compile - testCompile - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - prepare-package - - add-source - - - - src/main/scala - - - - - - - - - - release-sign-artifacts - - - performRelease - true - - - - - - org.apache.maven.plugins - maven-gpg-plugin - - - sign-artifacts - verify - - sign - - - - - - - - - - android-client - - - env - java - - - - samples/client/petstore/android/volley - - - - bash-client - - - env - java - - - - samples/client/petstore/bash - - - - clojure-client - - - env - clojure - - - - samples/client/petstore/clojure - - - - java-client-jersey1 - - - env - java - - - - samples/client/petstore/java/jersey1 - - - - java-client-jersey2 - - - env - java - - - - samples/client/petstore/java/jersey2 - - - - java-client-jersey2-java6 - - - env - java - - - - samples/client/petstore/java/jersey2-java6 - - - - java-client-okhttp-gson - - - env - java - - - - samples/client/petstore/java/okhttp-gson - - - - java-client-okhttp-gson-parcelable - - - env - java - - - - samples/client/petstore/java/okhttp-gson/parcelableModel - - - - java-client-retrofit - - - env - java - - - - samples/client/petstore/java/retrofit - - - - java-client-retrofit2 - - - env - java - - - - samples/client/petstore/java/retrofit2 - - - - java-client-retrofit2-rx - - - env - java - - - - samples/client/petstore/java/retrofit2rx - - - - java-client-feign - - - env - java - - - - samples/client/petstore/java/feign - - - - javascript-client - - - env - javascript - - - - samples/client/petstore/javascript - - - - scala-client - - - env - scala - - - - samples/client/petstore/scala - - - - java-msf4j-server - - - env - java - - - - samples/server/petstore/java-msf4/ - - - - jaxrs-cxf-server - - - env - java - - - - samples/server/petstore/jaxrs-cxf - - - - jaxrs-resteasy-server - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/default - - - - jaxrs-resteasy-server-joda - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/joda - - - - jaxrs-resteasy-eap-server - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/eap - - - - jaxrs-resteasy-eap-server-java8 - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/eap-java8 - - - - jaxrs-resteasy-eap-server-joda - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/eap-joda - - - - jaxrs-server - - - env - java - - - - samples/server/petstore/jaxrs/jersey2 - - - - jaxrs-server-jersey1 - - - env - java - - - - samples/server/petstore/jaxrs/jersey1 - - - - - jaxrs-jersey - - - env - java - - - - samples/server/petstore/jaxrs-jersey - - - - jaxrs-spec - - - env - java - - - - samples/server/petstore/jaxrs-spec - - - - jaxrs-spec-interface - - - env - java - - - - samples/server/petstore/jaxrs-spec-interface - - - - jaxrs-spec-interface-response - - - env - java - - - - samples/server/petstore/jaxrs-spec-interface-response - - - - typescript-fetch-client-tests-default - - - env - java - - - - samples/client/petstore/typescript-fetch/tests/default - - - - typescript-fetch-client-builds-default - - - env - java - - - - samples/client/petstore/typescript-fetch/builds/default - - - - typescript-fetch-client-builds-es6-target - - - env - java - - - - samples/client/petstore/typescript-fetch/builds/es6-target - - - - typescript-fetch-client-builds-with-npm-version - - - env - java - - - - samples/client/petstore/typescript-fetch/builds/with-npm-version - - - - typescript-angularjs-client - - - env - java - - - - samples/client/petstore/typescript-angularjs/npm - - - - typescript-node-npm-client - - - env - java - - - - samples/client/petstore/typescript-node/npm - - - - python-client - - - env - java - - - - samples/client/petstore/python - - - - ruby-client - - - env - java - - - - samples/client/petstore/ruby - - - - go-client - - - env - java - - - - samples/client/petstore/go - - - - spring-mvc - - - env - java - - - - samples/server/petstore/spring-mvc - - - - springboot-useoptional - - - env - java - - - - samples/server/petstore/springboot-useoptional - - - - springboot-beanvalidation - - - env - java - - - - samples/server/petstore/springboot-beanvalidation - - - - springboot-reactive - - - env - java - - - - samples/server/petstore/springboot-reactive - - - - springboot - - - env - java - - - - samples/server/petstore/springboot - - - - spring-cloud - - - env - java - - - - samples/client/petstore/spring-cloud - - - - scalatra-server - - - env - java - - - - samples/server/petstore/scalatra - - - - java-inflector - - - env - java - - - - samples/server/petstore/java-inflector - - - - java-undertowr - - - env - java - - - - samples/server/petstore/undertow - - - - samples - - - env - samples - - - - - - samples/client/petstore/go - samples/client/petstore/typescript-angular-v6-provided-in-root - - samples/client/petstore/scala-akka - samples/client/petstore/scala-httpclient - samples/client/petstore/scalaz - samples/client/petstore/clojure - samples/client/petstore/java/feign - samples/client/petstore/java/jersey1 - samples/client/petstore/java/jersey2 - samples/client/petstore/java/jersey2-java8 - samples/client/petstore/java/okhttp-gson - samples/client/petstore/java/retrofit - samples/client/petstore/java/retrofit2 - samples/client/petstore/java/retrofit2rx - samples/client/petstore/java/retrofit2-play25 - samples/client/petstore/jaxrs-cxf-client - samples/client/petstore/java/resttemplate - samples/client/petstore/java/resttemplate-withXml - samples/client/petstore/java/webclient - samples/client/petstore/java/vertx - samples/client/petstore/java/resteasy - samples/client/petstore/java/google-api-client - samples/client/petstore/java/rest-assured - samples/client/petstore/kotlin/ - samples/client/petstore/kotlin-threetenbp/ - samples/client/petstore/kotlin-string/ - - samples/server/petstore/jaxrs-jersey - samples/server/petstore/jaxrs-spec - samples/server/petstore/jaxrs-spec-interface - samples/server/petstore/jaxrs-spec-interface-response - samples/server/petstore/java-vertx/rx - samples/server/petstore/java-vertx/async - samples/server/petstore/java-inflector - samples/server/petstore/java-pkmst - samples/server/petstore/java-play-framework - samples/server/petstore/java-play-framework-no-wrap-calls - samples/server/petstore/java-play-framework-no-swagger-ui - samples/server/petstore/java-play-framework-no-interface - samples/server/petstore/java-play-framework-no-exception-handling - samples/server/petstore/java-play-framework-no-bean-validation - samples/server/petstore/java-play-framework-fake-endpoints - samples/server/petstore/java-play-framework-controller-only - samples/server/petstore/java-play-framework-api-package-override - samples/server/petstore/undertow - samples/server/petstore/jaxrs/jersey1 - samples/server/petstore/jaxrs/jersey1-useTags - - samples/server/petstore/jaxrs-datelib-j8 - samples/server/petstore/jaxrs-resteasy/default - samples/server/petstore/jaxrs-resteasy/eap - samples/server/petstore/jaxrs-resteasy/eap-joda - samples/server/petstore/jaxrs-resteasy/eap-java8 - samples/server/petstore/jaxrs-resteasy/joda - - - samples/client/petstore/spring-cloud - samples/server/petstore/springboot - samples/server/petstore/springboot-beanvalidation - samples/server/petstore/springboot-useoptional - samples/server/petstore/jaxrs-cxf - samples/server/petstore/jaxrs-cxf-annotated-base-path - samples/server/petstore/jaxrs-cxf-cdi - samples/server/petstore/jaxrs-cxf-non-spring-app - samples/server/petstore/java-msf4j - samples/server/petstore/scala-lagom-server - samples/server/petstore/scalatra - samples/server/petstore/finch - - - - - modules/openapi-generator - modules/openapi-generator-cli - modules/openapi-generator-maven-plugin - modules/openapi-generator-online - - - target/site - - - net.alchim31.maven - scala-maven-plugin - ${scala-maven-plugin-version} - - - org.apache.maven.plugins - maven-jxr-plugin - 2.5 - - true - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.9 - - - - project-team - - - - - - - - - - junit - junit - ${junit-version} - test - - - org.testng - testng - ${testng-version} - test - - - org.jmockit - jmockit - ${jmockit-version} - test - - - - - - sonatype-snapshots - https://oss.sonatype.org/content/repositories/snapshots - - true - - - - - 2.0.2-OpenAPITools.org-1 - 2.0.1 - 2.11.1 - 3.3.0 - 2.4 - 1.2 - 4.8.1 - 2.8.9 - 1.0.0 - 3.4 - 1.7.12 - 3.2.1 - 1.14 - 4.1.0 - 6.9.6 - 2.19.1 - 1.25 - 0.9.10 - 2.0.2.RELEASE - - diff --git a/CI/pom.xml.circleci.java7 b/CI/pom.xml.circleci.java7 deleted file mode 100644 index c38568172994..000000000000 --- a/CI/pom.xml.circleci.java7 +++ /dev/null @@ -1,1022 +0,0 @@ - - - - org.sonatype.oss - oss-parent - 5 - - 4.0.0 - org.openapitools - openapi-generator-project - pom - openapi-generator-project - 4.0.0-SNAPSHOT - https://github.com/openapitools/openapi-generator - - scm:git:git@github.com:openapitools/openapi-generator.git - scm:git:git@github.com:openapitools/openapi-generator.git - https://github.com/openapitools/openapi-generator - - - 2.2.0 - - - - - fehguy - Tony Tam - fehguy@gmail.com - - - - wing328 - William Cheng - wing328hk@gmail.com - - - jimschubert - Jim Schubert - james.schubert@gmail.com - - - cbornet - Christophe Bornet - - - jaz-ah - Joseph Zuromski - - - ackintosh - Akihito Nakano - - - JFCote - Jean-François Côté - - - jmini - Jérémie Bresson - dev@jmini.fr - - - - github - https://github.com/openapitools/openapi-generator/issues - - - - Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0.html - repo - - - - src/main/java - target/classes - - - org.jvnet.wagon-svn - wagon-svn - 1.8 - - - org.apache.maven.wagon - wagon-ssh-external - 1.0-alpha-6 - - - org.apache.maven.wagon - wagon-webdav - 1.0-beta-1 - - - install - target - ${project.artifactId}-${project.version} - - - net.revelc.code - formatter-maven-plugin - - - - 1.8 - 1.8 - 1.8 - LF - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire-version} - - none:none - -XX:+StartAttachListener - - - - test-testng - test - - test - - - none:none - org.testng:testng - - - - - - maven-dependency-plugin - - - package - - copy-dependencies - - - ${project.build.directory}/lib - - - - - - maven-compiler-plugin - 3.6.1 - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - - development - ${project.url} - ${project.version} - org.openapitools - - - - - - org.apache.maven.plugins - maven-site-plugin - 3.5.1 - - - org.apache.maven.plugins - maven-release-plugin - 2.5.3 - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.0.1 - - true - 1.8 - UTF-8 - 1g - true - ${javadoc.package.exclude} - - - - attach-javadocs - verify - - jar - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.0.1 - - - attach-sources - verify - - jar-no-fork - - - - - - - - - net.revelc.code - formatter-maven-plugin - 0.5.2 - - - - - - - release-profile - - true - - - - - net.alchim31.maven - scala-maven-plugin - - - - compile - testCompile - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - prepare-package - - add-source - - - - src/main/scala - - - - - - - - - - release-sign-artifacts - - - performRelease - true - - - - - - org.apache.maven.plugins - maven-gpg-plugin - - - sign-artifacts - verify - - sign - - - - - - - - - - android-client - - - env - java - - - - samples/client/petstore/android/volley - - - - bash-client - - - env - java - - - - samples/client/petstore/bash - - - - clojure-client - - - env - clojure - - - - samples/client/petstore/clojure - - - - java-client-jersey1 - - - env - java - - - - samples/client/petstore/java/jersey1 - - - - java-client-jersey2 - - - env - java - - - - samples/client/petstore/java/jersey2 - - - - java-client-jersey2-java6 - - - env - java - - - - samples/client/petstore/java/jersey2-java6 - - - - java-client-okhttp-gson - - - env - java - - - - samples/client/petstore/java/okhttp-gson - - - - java-client-okhttp-gson-parcelable - - - env - java - - - - samples/client/petstore/java/okhttp-gson/parcelableModel - - - - java-client-retrofit - - - env - java - - - - samples/client/petstore/java/retrofit - - - - java-client-retrofit2 - - - env - java - - - - samples/client/petstore/java/retrofit2 - - - - java-client-retrofit2-rx - - - env - java - - - - samples/client/petstore/java/retrofit2rx - - - - java-client-feign - - - env - java - - - - samples/client/petstore/java/feign - - - - javascript-client - - - env - javascript - - - - samples/client/petstore/javascript - - - - scala-client - - - env - scala - - - - samples/client/petstore/scala - - - - java-msf4j-server - - - env - java - - - - samples/server/petstore/java-msf4/ - - - - jaxrs-cxf-server - - - env - java - - - - samples/server/petstore/jaxrs-cxf - - - - jaxrs-resteasy-server - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/default - - - - jaxrs-resteasy-server-joda - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/joda - - - - jaxrs-resteasy-eap-server - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/eap - - - - jaxrs-resteasy-eap-server-java8 - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/eap-java8 - - - - jaxrs-resteasy-eap-server-joda - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/eap-joda - - - - jaxrs-server - - - env - java - - - - samples/server/petstore/jaxrs/jersey2 - - - - jaxrs-server-jersey1 - - - env - java - - - - samples/server/petstore/jaxrs/jersey1 - - - - - jaxrs-jersey - - - env - java - - - - samples/server/petstore/jaxrs-jersey - - - - jaxrs-spec - - - env - java - - - - samples/server/petstore/jaxrs-spec - - - - jaxrs-spec-interface - - - env - java - - - - samples/server/petstore/jaxrs-spec-interface - - - - jaxrs-spec-interface-response - - - env - java - - - - samples/server/petstore/jaxrs-spec-interface-response - - - - typescript-fetch-client-tests-default - - - env - java - - - - samples/client/petstore/typescript-fetch/tests/default - - - - typescript-fetch-client-builds-default - - - env - java - - - - samples/client/petstore/typescript-fetch/builds/default - - - - typescript-fetch-client-builds-es6-target - - - env - java - - - - samples/client/petstore/typescript-fetch/builds/es6-target - - - - typescript-fetch-client-builds-with-npm-version - - - env - java - - - - samples/client/petstore/typescript-fetch/builds/with-npm-version - - - - typescript-angularjs-client - - - env - java - - - - samples/client/petstore/typescript-angularjs/npm - - - - typescript-node-npm-client - - - env - java - - - - samples/client/petstore/typescript-node/npm - - - - python-client - - - env - java - - - - samples/client/petstore/python - - - - ruby-client - - - env - java - - - - samples/client/petstore/ruby - - - - go-client - - - env - java - - - - samples/client/petstore/go - - - - spring-mvc - - - env - java - - - - samples/server/petstore/spring-mvc - - - - springboot-useoptional - - - env - java - - - - samples/server/petstore/springboot-useoptional - - - - springboot-beanvalidation - - - env - java - - - - samples/server/petstore/springboot-beanvalidation - - - - springboot-reactive - - - env - java - - - - samples/server/petstore/springboot-reactive - - - - springboot - - - env - java - - - - samples/server/petstore/springboot - - - - spring-cloud - - - env - java - - - - samples/client/petstore/spring-cloud - - - - scalatra-server - - - env - java - - - - samples/server/petstore/scalatra - - - - java-inflector - - - env - java - - - - samples/server/petstore/java-inflector - - - - java-undertowr - - - env - java - - - - samples/server/petstore/undertow - - - - samples - - - env - samples - - - - - - samples/client/petstore/scala-akka - samples/client/petstore/scala-httpclient - samples/client/petstore/scalaz - samples/client/petstore/java/feign - samples/client/petstore/java/jersey1 - samples/client/petstore/java/jersey2 - samples/client/petstore/java/okhttp-gson - samples/client/petstore/java/retrofit - samples/client/petstore/java/retrofit2 - samples/client/petstore/java/retrofit2rx - samples/client/petstore/jaxrs-cxf-client - samples/client/petstore/java/resttemplate - samples/client/petstore/java/resttemplate-withXml - samples/client/petstore/java/vertx - samples/client/petstore/java/resteasy - samples/client/petstore/java/google-api-client - samples/client/petstore/kotlin/ - - samples/server/petstore/jaxrs-jersey - samples/server/petstore/jaxrs-spec - samples/server/petstore/jaxrs-spec-interface - samples/server/petstore/jaxrs-spec-interface-response - samples/server/petstore/java-vertx/rx - samples/server/petstore/java-vertx/async - samples/server/petstore/java-inflector - samples/server/petstore/undertow - samples/server/petstore/jaxrs/jersey1 - samples/server/petstore/jaxrs/jersey2 - samples/server/petstore/jaxrs/jersey1-useTags - samples/server/petstore/jaxrs/jersey2-useTags - samples/server/petstore/jaxrs-resteasy/default - samples/server/petstore/jaxrs-resteasy/eap - samples/server/petstore/jaxrs-resteasy/eap-joda - samples/server/petstore/jaxrs-resteasy/eap-java8 - samples/server/petstore/jaxrs-resteasy/joda - samples/server/petstore/spring-mvc - samples/client/petstore/spring-cloud - samples/server/petstore/springboot - samples/server/petstore/springboot-beanvalidation - samples/server/petstore/springboot-useoptional - samples/server/petstore/jaxrs-cxf - samples/server/petstore/jaxrs-cxf-annotated-base-path - samples/server/petstore/jaxrs-cxf-cdi - samples/server/petstore/jaxrs-cxf-non-spring-app - samples/server/petstore/java-msf4j - - - - - modules/openapi-generator - modules/openapi-generator-cli - modules/openapi-generator-maven-plugin - modules/openapi-generator-online - - - target/site - - - net.alchim31.maven - scala-maven-plugin - ${scala-maven-plugin-version} - - - org.apache.maven.plugins - maven-jxr-plugin - 2.5 - - true - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.9 - - - - project-team - - - - - - - - - - junit - junit - ${junit-version} - test - - - org.testng - testng - ${testng-version} - test - - - org.jmockit - jmockit - ${jmockit-version} - test - - - - - - sonatype-snapshots - https://oss.sonatype.org/content/repositories/snapshots - - true - - - - - 2.0.2-OpenAPITools.org-1 - 2.0.1 - 2.11.1 - 3.3.0 - 2.4 - 1.2 - 4.8.1 - 2.8.9 - 1.0.0 - 3.4 - 1.7.12 - 3.2.1 - 1.12 - 4.1.0 - 6.9.6 - 2.19.1 - 1.25 - 0.9.10 - 2.0.2.RELEASE - - diff --git a/CI/pom.xml.ios b/CI/pom.xml.ios deleted file mode 100644 index 2c037c238f38..000000000000 --- a/CI/pom.xml.ios +++ /dev/null @@ -1,951 +0,0 @@ - - - org.sonatype.oss - oss-parent - 5 - - 4.0.0 - org.openapitools - openapi-generator-project - pom - openapi-generator-project - 4.0.0-SNAPSHOT - https://github.com/openapitools/openapi-generator - - scm:git:git@github.com:openapitools/openapi-generator.git - scm:git:git@github.com:openapitools/openapi-generator.git - https://github.com/openapitools/openapi-generator - - - - - fehguy - Tony Tam - fehguy@gmail.com - - - - wing328 - William Cheng - wing328hk@gmail.com - - - jimschubert - Jim Schubert - james.schubert@gmail.com - - - cbornet - Christophe Bornet - - - jaz-ah - Joseph Zuromski - - - ackintosh - Akihito Nakano - - - JFCote - Jean-François Côté - - - jmini - Jérémie Bresson - dev@jmini.fr - - - - github - https://github.com/openapitools/openapi-generator/issues - - - - Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0.html - repo - - - - src/main/java - target/classes - - - org.jvnet.wagon-svn - wagon-svn - 1.8 - - - org.apache.maven.wagon - wagon-ssh-external - 1.0-alpha-6 - - - org.apache.maven.wagon - wagon-webdav - 1.0-beta-1 - - - install - target - ${project.artifactId}-${project.version} - - - net.revelc.code - formatter-maven-plugin - - - - 1.8 - 1.8 - 1.8 - LF - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire-version} - - none:none - -XX:+StartAttachListener - - - - test-testng - test - - test - - - none:none - org.testng:testng - - - - - - maven-dependency-plugin - - - package - - copy-dependencies - - - ${project.build.directory}/lib - - - - - - maven-compiler-plugin - 3.6.1 - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - - development - ${project.url} - ${project.version} - org.openapitools - - - - - - org.apache.maven.plugins - maven-site-plugin - 3.5.1 - - - org.apache.maven.plugins - maven-release-plugin - 2.5.3 - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.0.1 - - true - 1.8 - UTF-8 - 1g - true - ${javadoc.package.exclude} - - - - attach-javadocs - verify - - jar - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.0.1 - - - attach-sources - verify - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - 1.4.1 - - - enforce-versions - - enforce - - - - - 3.2.5 - - - - - - - - - - - net.revelc.code - formatter-maven-plugin - 0.5.2 - - - - - - - release-profile - - true - - - - - net.alchim31.maven - scala-maven-plugin - - - - compile - testCompile - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - prepare-package - - add-source - - - - src/main/scala - - - - - - - - - - release-sign-artifacts - - - performRelease - true - - - - - - org.apache.maven.plugins - maven-gpg-plugin - - - sign-artifacts - verify - - sign - - - - - - - - - - android-client - - - env - java - - - - samples/client/petstore/android/volley - - - - bash-client - - - env - java - - - - samples/client/petstore/bash - - - - clojure-client - - - env - clojure - - - - samples/client/petstore/clojure - - - - haskell-http-client - - - env - haskell-http-client - - - - samples/client/petstore/haskell-http-client - - - - haskell-http-client-integration-test - - - env - haskell-http-client - - - - samples/client/petstore/haskell-http-client/tests-integration - - - - java-client-jersey1 - - - env - java - - - - samples/client/petstore/java/jersey1 - - - - java-client-jersey2 - - - env - java - - - - samples/client/petstore/java/jersey2 - - - - java-client-jersey2-java6 - - - env - java - - - - samples/client/petstore/java/jersey2-java6 - - - - java-client-okhttp-gson - - - env - java - - - - samples/client/petstore/java/okhttp-gson - - - - java-client-okhttp-gson-parcelable - - - env - java - - - - samples/client/petstore/java/okhttp-gson/parcelableModel - - - - java-client-retrofit - - - env - java - - - - samples/client/petstore/java/retrofit - - - - java-client-retrofit2 - - - env - java - - - - samples/client/petstore/java/retrofit2 - - - - java-client-retrofit2-rx - - - env - java - - - - samples/client/petstore/java/retrofit2rx - - - - java-client-feign - - - env - java - - - - samples/client/petstore/java/feign - - - - javascript-client - - - env - javascript - - - - samples/client/petstore/javascript - - - - scala-client - - - env - scala - - - - samples/client/petstore/scala - - - - java-msf4j-server - - - env - java - - - - samples/server/petstore/java-msf4/ - - - - jaxrs-cxf-server - - - env - java - - - - samples/server/petstore/jaxrs-cxf - - - - jaxrs-resteasy-server - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/default - - - - jaxrs-resteasy-server-joda - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/joda - - - - jaxrs-resteasy-eap-server - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/eap - - - - jaxrs-resteasy-eap-server-joda - - - env - java - - - - samples/server/petstore/jaxrs-resteasy/eap-joda - - - - jaxrs-server - - - env - java - - - - samples/server/petstore/jaxrs/jersey2 - - - - jaxrs-server-jersey1 - - - env - java - - - - samples/server/petstore/jaxrs/jersey1 - - - - typescript-fetch-client-tests-default - - - env - java - - - - samples/client/petstore/typescript-fetch/tests/default - - - - typescript-fetch-client-builds-default - - - env - java - - - - samples/client/petstore/typescript-fetch/builds/default - - - - typescript-fetch-client-builds-es6-target - - - env - java - - - - samples/client/petstore/typescript-fetch/builds/es6-target - - - - typescript-fetch-client-builds-with-npm-version - - - env - java - - - - samples/client/petstore/typescript-fetch/builds/with-npm-version - - - - typescript-angularjs-client - - - env - java - - - - samples/client/petstore/typescript-angularjs/npm - - - - typescript-node-npm-client - - - env - java - - - - samples/client/petstore/typescript-node/npm - - - - python-client - - - env - java - - - - samples/client/petstore/python - - - - ruby-client - - - env - java - - - - samples/client/petstore/ruby - - - - go-client - - - env - java - - - - samples/client/petstore/go - - - - spring-mvc - - - env - java - - - - samples/server/petstore/spring-mvc - - - - springboot-beanvalidation - - - env - java - - - - samples/server/petstore/springboot-beanvalidation - - - - springboot-reactive - - - env - java - - - - samples/server/petstore/springboot-reactive - - - - springboot - - - env - java - - - - samples/server/petstore/springboot - - - - spring-cloud - - - env - java - - - - samples/client/petstore/spring-cloud - - - - scalatra-server - - - env - java - - - - samples/server/petstore/scalatra - - - - java-inflector - - - env - java - - - - samples/server/petstore/java-inflector - - - - java-undertowr - - - env - java - - - - samples/server/petstore/undertow - - - - samples - - - env - samples - - - - samples/client/petstore/swift3/default/SwaggerClientTests - samples/client/petstore/swift3/promisekit/SwaggerClientTests - samples/client/petstore/swift3/rxswift/SwaggerClientTests - samples/client/petstore/swift/default/SwaggerClientTests - samples/client/petstore/swift/promisekit/SwaggerClientTests - samples/client/petstore/swift/rxswift/SwaggerClientTests - - - - - - modules/openapi-generator - modules/openapi-generator-cli - modules/openapi-generator-maven-plugin - modules/openapi-generator-online - - - target/site - - - net.alchim31.maven - scala-maven-plugin - ${scala-maven-plugin-version} - - - org.apache.maven.plugins - maven-jxr-plugin - 2.5 - - true - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.9 - - - - project-team - - - - - - - - - - junit - junit - ${junit-version} - test - - - org.testng - testng - ${testng-version} - test - - - org.jmockit - jmockit - ${jmockit-version} - test - - - - - - sonatype-snapshots - https://oss.sonatype.org/content/repositories/snapshots - - true - - - - - 2.0.2-OpenAPITools.org-1 - 2.0.1 - 2.11.1 - 3.3.0 - 2.4 - 1.2 - 4.8.1 - 2.8.9 - 1.0.0 - 3.4 - 1.7.12 - 3.2.1 - 1.14 - 4.1.0 - 6.9.6 - 2.19.1 - 1.25 - 0.9.10 - 2.0.2.RELEASE - - diff --git a/CI/samples.ci/client/petstore/csharp-refactor/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj b/CI/samples.ci/client/petstore/csharp-refactor/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj new file mode 100644 index 000000000000..0dcd528d4c64 --- /dev/null +++ b/CI/samples.ci/client/petstore/csharp-refactor/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj @@ -0,0 +1,91 @@ + + + + + Debug + AnyCPU + {19F1DEBC-DE5E-4517-8062-F000CD499087} + Library + Properties + Org.OpenAPITools.Test + Org.OpenAPITools.Test + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + $(SolutionDir)\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + ..\..\vendor\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + + + $(SolutionDir)\packages\JsonSubTypes.1.5.1\lib\net45\JsonSubTypes.dll + ..\packages\JsonSubTypes.1.5.1\lib\net45\JsonSubTypes.dll + ..\..\packages\JsonSubTypes.1.5.1\lib\net45\JsonSubTypes.dll + ..\..\vendor\JsonSubTypes.1.5.1\lib\net45\JsonSubTypes.dll + + + $(SolutionDir)\packages\RestSharp.106.5.4\lib\net452\RestSharp.dll + ..\packages\RestSharp.106.5.4\lib\net452\RestSharp.dll + ..\..\packages\RestSharp.106.5.4\lib\net452\RestSharp.dll + ..\..\vendor\RestSharp.106.5.4\lib\net452\RestSharp.dll + + + $(SolutionDir)\packages\NUnit.2.6.4\lib\nunit.framework.dll + ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + ..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll + ..\..\vendor\NUnit.2.6.4\lib\nunit.framework.dll + + + + + + + + + + + + {321C8C3F-0156-40C1-AE42-D59761FB9B6C} + Org.OpenAPITools + + + + + + + diff --git a/CI/samples.ci/client/petstore/java/test-manual/jersey1/ApiClientTest.java b/CI/samples.ci/client/petstore/java/test-manual/jersey1/ApiClientTest.java index a890ead935f8..405267d4131f 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/jersey1/ApiClientTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/jersey1/ApiClientTest.java @@ -28,7 +28,7 @@ public void testParseAndFormatDate() { assertEquals(dateStr, apiClient.formatDate(apiClient.parseDate("2015-11-07T02:49:09.356-01:00"))); // custom date format: without milli-seconds, custom time zone - DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); + DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX", Locale.ROOT); format.setTimeZone(TimeZone.getTimeZone("GMT+10")); apiClient.setDateFormat(format); dateStr = "2015-11-07T13:49:09+10:00"; diff --git a/CI/samples.ci/client/petstore/java/test-manual/jersey2/ApiClientTest.java b/CI/samples.ci/client/petstore/java/test-manual/jersey2/ApiClientTest.java index 6fb1e54b679b..09659fb4700b 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/jersey2/ApiClientTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/jersey2/ApiClientTest.java @@ -28,7 +28,7 @@ public void testParseAndFormatDate() { assertEquals(dateStr, apiClient.formatDate(apiClient.parseDate("2015-11-07T02:49:09.356-01:00"))); // custom date format: without milli-seconds, custom time zone - DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); + DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX", Locale.ROOT); format.setTimeZone(TimeZone.getTimeZone("GMT+10")); apiClient.setDateFormat(format); dateStr = "2015-11-07T13:49:09+10:00"; diff --git a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/ApiClientTest.java b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/ApiClientTest.java index 5167afc326b6..4d8b5d2b38fe 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/ApiClientTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/ApiClientTest.java @@ -157,11 +157,11 @@ public void testSetApiKeyAndPrefix() { public void testGetAndSetConnectTimeout() { // connect timeout defaults to 10 seconds assertEquals(10000, apiClient.getConnectTimeout()); - assertEquals(10000, apiClient.getHttpClient().getConnectTimeout()); + assertEquals(10000, apiClient.getHttpClient().connectTimeoutMillis()); apiClient.setConnectTimeout(0); assertEquals(0, apiClient.getConnectTimeout()); - assertEquals(0, apiClient.getHttpClient().getConnectTimeout()); + assertEquals(0, apiClient.getHttpClient().connectTimeoutMillis()); apiClient.setConnectTimeout(10000); } @@ -170,11 +170,11 @@ public void testGetAndSetConnectTimeout() { public void testGetAndSetReadTimeout() { // read timeout defaults to 10 seconds assertEquals(10000, apiClient.getReadTimeout()); - assertEquals(10000, apiClient.getHttpClient().getReadTimeout()); + assertEquals(10000, apiClient.getHttpClient().readTimeoutMillis()); apiClient.setReadTimeout(0); assertEquals(0, apiClient.getReadTimeout()); - assertEquals(0, apiClient.getHttpClient().getReadTimeout()); + assertEquals(0, apiClient.getHttpClient().readTimeoutMillis()); apiClient.setReadTimeout(10000); } @@ -183,11 +183,11 @@ public void testGetAndSetReadTimeout() { public void testGetAndSetWriteTimeout() { // write timeout defaults to 10 seconds assertEquals(10000, apiClient.getWriteTimeout()); - assertEquals(10000, apiClient.getHttpClient().getWriteTimeout()); + assertEquals(10000, apiClient.getHttpClient().writeTimeoutMillis()); apiClient.setWriteTimeout(0); assertEquals(0, apiClient.getWriteTimeout()); - assertEquals(0, apiClient.getHttpClient().getWriteTimeout()); + assertEquals(0, apiClient.getHttpClient().writeTimeoutMillis()); apiClient.setWriteTimeout(10000); } diff --git a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/JSONTest.java b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/JSONTest.java index e7687d0b33b1..1c825e392562 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/JSONTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/JSONTest.java @@ -12,6 +12,7 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; +import java.util.Locale; import java.util.TimeZone; import okio.ByteString; @@ -46,7 +47,7 @@ public void testSqlDateTypeAdapter() { assertEquals(json.deserialize("\"2015-11-07T03:49:09.356" + getCurrentTimezoneOffset() + "\"", java.sql.Date.class).toString(), date.toString()); // custom date format: without day - DateFormat format = new SimpleDateFormat("yyyy-MM"); + DateFormat format = new SimpleDateFormat("yyyy-MM", Locale.ROOT); apiClient.setSqlDateFormat(format); String dateStr = "\"2015-11\""; assertEquals(dateStr, json.serialize(json.deserialize("\"2015-11-07T03:49:09Z\"", java.sql.Date.class))); @@ -79,7 +80,7 @@ public void testDateTypeAdapter() { assertEquals(utcDate, json.serialize(date)); // custom datetime format: without milli-seconds, custom time zone - DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); + DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX", Locale.ROOT); format.setTimeZone(TimeZone.getTimeZone("GMT+10")); apiClient.setDateFormat(format); @@ -190,10 +191,10 @@ public void testByteArrayTypeAdapterDeserialization() { public static String getCurrentTimezoneOffset() { TimeZone tz = TimeZone.getDefault(); - Calendar cal = GregorianCalendar.getInstance(tz); + Calendar cal = GregorianCalendar.getInstance(tz, Locale.ROOT); int offsetInMillis = tz.getOffset(cal.getTimeInMillis()); - String offset = String.format("%02d:%02d", Math.abs(offsetInMillis / 3600000), Math.abs((offsetInMillis / 60000) % 60)); + String offset = String.format(Locale.ROOT,"%02d:%02d", Math.abs(offsetInMillis / 3600000), Math.abs((offsetInMillis / 60000) % 60)); offset = (offsetInMillis >= 0 ? "+" : "-") + offset; return offset; diff --git a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/api/PetApiTest.java b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/api/PetApiTest.java new file mode 100644 index 000000000000..416b12609e72 --- /dev/null +++ b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/api/PetApiTest.java @@ -0,0 +1,358 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.api; + +import org.openapitools.client.ApiException; +import org.openapitools.client.model.Pet; +import org.openapitools.client.auth.*; +import org.openapitools.client.model.*; +import org.openapitools.client.*; + +import java.lang.reflect.Type; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; + +import org.junit.*; + +import static org.junit.Assert.*; + +/** + * API tests for PetApi + */ +public class PetApiTest { + + private PetApi api = new PetApi(); + + @Before + public void setup() { + // setup authentication + ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key"); + apiKeyAuth.setApiKey("special-key"); + } + + @Test + public void testApiClient() { + // the default api client is used + assertEquals(Configuration.getDefaultApiClient(), api.getApiClient()); + assertNotNull(api.getApiClient()); + assertEquals("http://petstore.swagger.io:80/v2", api.getApiClient().getBasePath()); + assertFalse(api.getApiClient().isDebugging()); + + ApiClient oldClient = api.getApiClient(); + + ApiClient newClient = new ApiClient(); + newClient.setBasePath("http://example.com"); + newClient.setDebugging(true); + + // set api client via constructor + api = new PetApi(newClient); + assertNotNull(api.getApiClient()); + assertEquals("http://example.com", api.getApiClient().getBasePath()); + assertTrue(api.getApiClient().isDebugging()); + + // set api client via setter method + api.setApiClient(oldClient); + assertNotNull(api.getApiClient()); + assertEquals("http://petstore.swagger.io:80/v2", api.getApiClient().getBasePath()); + assertFalse(api.getApiClient().isDebugging()); + } + + @Test + public void testCreateAndGetPet() throws Exception { + Pet pet = createPet(); + api.addPet(pet); + + Pet fetched = api.getPetById(pet.getId()); + assertNotNull(fetched); + assertEquals(pet.getId(), fetched.getId()); + assertNotNull(fetched.getCategory()); + assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); + } + + @Test + public void testCreateAndGetPetWithHttpInfo() throws Exception { + Pet pet = createPet(); + api.addPetWithHttpInfo(pet); + + ApiResponse resp = api.getPetByIdWithHttpInfo(pet.getId()); + assertEquals(200, resp.getStatusCode()); + assertEquals("application/json", resp.getHeaders().get("Content-Type").get(0)); + Pet fetched = resp.getData(); + assertNotNull(fetched); + assertEquals(pet.getId(), fetched.getId()); + assertNotNull(fetched.getCategory()); + assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); + } + + @Test + public void testCreateAndGetPetAsync() throws Exception { + Pet pet = createPet(); + api.addPet(pet); + // to store returned Pet or error message/exception + final Map result = new HashMap(); + + api.getPetByIdAsync(pet.getId(), new ApiCallback() { + @Override + public void onFailure(ApiException e, int statusCode, Map> responseHeaders) { + result.put("error", e.getMessage()); + } + + @Override + public void onSuccess(Pet pet, int statusCode, Map> responseHeaders) { + result.put("pet", pet); + } + + @Override + public void onUploadProgress(long bytesWritten, long contentLength, boolean done) { + //empty + } + + @Override + public void onDownloadProgress(long bytesRead, long contentLength, boolean done) { + //empty + } + }); + // the API call should be executed asynchronously, so result should be empty at the moment + assertTrue(result.isEmpty()); + + // wait for the asynchronous call to finish (at most 10 seconds) + final int maxTry = 10; + int tryCount = 1; + Pet fetched = null; + do { + if (tryCount > maxTry) fail("have not got result of getPetByIdAsync after 10 seconds"); + Thread.sleep(1000); + tryCount += 1; + if (result.get("error") != null) fail((String) result.get("error")); + if (result.get("pet") != null) { + fetched = (Pet) result.get("pet"); + break; + } + } while (result.isEmpty()); + assertNotNull(fetched); + assertEquals(pet.getId(), fetched.getId()); + assertNotNull(fetched.getCategory()); + assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); + + // test getting a nonexistent pet + result.clear(); + api.getPetByIdAsync(-10000L, new ApiCallback() { + @Override + public void onFailure(ApiException e, int statusCode, Map> responseHeaders) { + result.put("exception", e); + } + + @Override + public void onSuccess(Pet pet, int statusCode, Map> responseHeaders) { + result.put("pet", pet); + } + + @Override + public void onUploadProgress(long bytesWritten, long contentLength, boolean done) { + //empty + } + + @Override + public void onDownloadProgress(long bytesRead, long contentLength, boolean done) { + //empty + } + }); + + // wait for the asynchronous call to finish (at most 10 seconds) + tryCount = 1; + ApiException exception = null; + do { + if (tryCount > maxTry) fail("have not got result of getPetByIdAsync after 10 seconds"); + Thread.sleep(1000); + tryCount += 1; + if (result.get("pet") != null) fail("expected an error"); + if (result.get("exception") != null) { + exception = (ApiException) result.get("exception"); + break; + } + } while (result.isEmpty()); + assertNotNull(exception); + assertEquals(404, exception.getCode()); + assertEquals("Not Found", exception.getMessage()); + assertEquals("application/json", exception.getResponseHeaders().get("Content-Type").get(0)); + } + + @Test + public void testUpdatePet() throws Exception { + Pet pet = createPet(); + pet.setName("programmer"); + + api.updatePet(pet); + + Pet fetched = api.getPetById(pet.getId()); + assertNotNull(fetched); + assertEquals(pet.getId(), fetched.getId()); + assertNotNull(fetched.getCategory()); + assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); + } + + @Test + public void testFindPetsByStatus() throws Exception { + Pet pet = createPet(); + pet.setName("programmer"); + pet.setStatus(Pet.StatusEnum.PENDING); + + api.updatePet(pet); + + List pets = api.findPetsByStatus(Arrays.asList("pending")); + assertNotNull(pets); + + boolean found = false; + for (Pet fetched : pets) { + if (fetched.getId().equals(pet.getId())) { + found = true; + break; + } + } + + assertTrue(found); + + api.deletePet(pet.getId(), null); + } + + @Test + public void testFindPetsByTags() throws Exception { + Pet pet = createPet(); + pet.setName("monster"); + pet.setStatus(Pet.StatusEnum.AVAILABLE); + + List tags = new ArrayList(); + Tag tag1 = new Tag(); + tag1.setName("friendly"); + tags.add(tag1); + pet.setTags(tags); + + api.updatePet(pet); + + List pets = api.findPetsByTags(Arrays.asList("friendly")); + assertNotNull(pets); + + boolean found = false; + for (Pet fetched : pets) { + if (fetched.getId().equals(pet.getId())) { + found = true; + break; + } + } + assertTrue(found); + + api.deletePet(pet.getId(), null); + } + + @Test + public void testUpdatePetWithForm() throws Exception { + Pet pet = createPet(); + pet.setName("frank"); + api.addPet(pet); + + Pet fetched = api.getPetById(pet.getId()); + + api.updatePetWithForm(fetched.getId(), "furt", null); + Pet updated = api.getPetById(fetched.getId()); + + assertEquals(updated.getName(), "furt"); + } + + @Test + public void testDeletePet() throws Exception { + Pet pet = createPet(); + api.addPet(pet); + + Pet fetched = api.getPetById(pet.getId()); + api.deletePet(fetched.getId(), null); + + try { + fetched = api.getPetById(fetched.getId()); + fail("expected an error"); + } catch (ApiException e) { + assertEquals(404, e.getCode()); + } + } + + @Test + public void testUploadFile() throws Exception { + Pet pet = createPet(); + api.addPet(pet); + + File file = new File("hello.txt"); + BufferedWriter writer = new BufferedWriter(new FileWriter(file)); + writer.write("Hello world!"); + writer.close(); + + api.uploadFile(pet.getId(), "a test file", new File(file.getAbsolutePath())); + } + + @Test + public void testEqualsAndHashCode() { + Pet pet1 = new Pet(); + Pet pet2 = new Pet(); + assertTrue(pet1.equals(pet2)); + assertTrue(pet2.equals(pet1)); + assertTrue(pet1.hashCode() == pet2.hashCode()); + assertTrue(pet1.equals(pet1)); + assertTrue(pet1.hashCode() == pet1.hashCode()); + + pet2.setName("really-happy"); + pet2.setPhotoUrls(Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2")); + assertFalse(pet1.equals(pet2)); + assertFalse(pet2.equals(pet1)); + assertFalse(pet1.hashCode() == (pet2.hashCode())); + assertTrue(pet2.equals(pet2)); + assertTrue(pet2.hashCode() == pet2.hashCode()); + + pet1.setName("really-happy"); + pet1.setPhotoUrls(Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2")); + assertTrue(pet1.equals(pet2)); + assertTrue(pet2.equals(pet1)); + assertTrue(pet1.hashCode() == pet2.hashCode()); + assertTrue(pet1.equals(pet1)); + assertTrue(pet1.hashCode() == pet1.hashCode()); + } + + + private Pet createPet() { + Pet pet = new Pet(); + pet.setId(1234567L); + pet.setName("gorilla"); + + Category category = new Category(); + category.setName("really-happy"); + + pet.setCategory(category); + pet.setStatus(Pet.StatusEnum.AVAILABLE); + List photos = Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2"); + pet.setPhotoUrls(photos); + + return pet; + } + + private String serializeJson(Object o, ApiClient apiClient) { + return apiClient.getJSON().serialize(o); + } + + private T deserializeJson(String json, Type type, ApiClient apiClient) { + return (T) apiClient.getJSON().deserialize(json, type); + } +} diff --git a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/model/ArrayOfArrayOfNumberOnlyTest.java b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/model/ArrayOfArrayOfNumberOnlyTest.java new file mode 100644 index 000000000000..73f0b3c6f5c3 --- /dev/null +++ b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/model/ArrayOfArrayOfNumberOnlyTest.java @@ -0,0 +1,70 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ArrayOfArrayOfNumberOnly + */ +public class ArrayOfArrayOfNumberOnlyTest { + private final ArrayOfArrayOfNumberOnly model = new ArrayOfArrayOfNumberOnly(); + + /** + * Model tests for ArrayOfArrayOfNumberOnly + */ + @Test + public void test() { + // TODO: test ArrayOfArrayOfNumberOnly + } + + /** + * Test the property 'arrayArrayNumber' + */ + @Test + public void arrayArrayNumberTest() { + BigDecimal b1 = new BigDecimal("12.3"); + BigDecimal b2 = new BigDecimal("5.6"); + List arrayArrayNumber = new ArrayList(); + arrayArrayNumber.add(b1); + arrayArrayNumber.add(b2); + model.getArrayArrayNumber().add(arrayArrayNumber); + + // create another instance for comparison + BigDecimal b3 = new BigDecimal("12.3"); + BigDecimal b4 = new BigDecimal("5.6"); + ArrayOfArrayOfNumberOnly model2 = new ArrayOfArrayOfNumberOnly(); + List arrayArrayNumber2 = new ArrayList(); + arrayArrayNumber2.add(b1); + arrayArrayNumber2.add(b2); + model2.getArrayArrayNumber().add(arrayArrayNumber2); + + Assert.assertTrue(model2.equals(model)); + } + +} diff --git a/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/model/PetTest.java b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/model/PetTest.java new file mode 100644 index 000000000000..3f4c1e8365d7 --- /dev/null +++ b/CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/model/PetTest.java @@ -0,0 +1,103 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.client.model.Category; +import org.openapitools.client.model.Tag; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for Pet + */ +public class PetTest { + private final Pet model = new Pet(); + + /** + * Model tests for Pet + */ + @Test + public void testPet() { + // test Pet + model.setId(1029L); + model.setName("Dog"); + + Pet model2 = new Pet(); + model2.setId(1029L); + model2.setName("Dog"); + + Assert.assertTrue(model.equals(model2)); + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'category' + */ + @Test + public void categoryTest() { + // TODO: test category + } + + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } + + /** + * Test the property 'photoUrls' + */ + @Test + public void photoUrlsTest() { + // TODO: test photoUrls + } + + /** + * Test the property 'tags' + */ + @Test + public void tagsTest() { + // TODO: test tags + } + + /** + * Test the property 'status' + */ + @Test + public void statusTest() { + // TODO: test status + } + +} diff --git a/CI/samples.ci/client/petstore/java/test-manual/resttemplate/ApiClientTest.java b/CI/samples.ci/client/petstore/java/test-manual/resttemplate/ApiClientTest.java index 2113f5d24535..a6bedae3e959 100644 --- a/CI/samples.ci/client/petstore/java/test-manual/resttemplate/ApiClientTest.java +++ b/CI/samples.ci/client/petstore/java/test-manual/resttemplate/ApiClientTest.java @@ -34,7 +34,7 @@ public void testParseAndFormatDate() { assertEquals(dateStr, apiClient.formatDate(apiClient.parseDate("2015-11-07T02:49:09.356-01:00"))); // custom date format: without milli-seconds, custom time zone - DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); + DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX", Locale.ROOT); format.setTimeZone(TimeZone.getTimeZone("GMT+10")); apiClient.setDateFormat(format); dateStr = "2015-11-07T13:49:09+10:00"; diff --git a/CI/samples.ci/client/petstore/typescript-fetch/builds/default/pom.xml b/CI/samples.ci/client/petstore/typescript-fetch/builds/default/pom.xml new file mode 100644 index 000000000000..b40b83a0c751 --- /dev/null +++ b/CI/samples.ci/client/petstore/typescript-fetch/builds/default/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + org.openapitools + TypeScriptAngularBuildPestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch Default Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + + diff --git a/CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target/pom.xml b/CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target/pom.xml new file mode 100644 index 000000000000..db6dfdfeb6aa --- /dev/null +++ b/CI/samples.ci/client/petstore/typescript-fetch/builds/es6-target/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + org.openapitools + TypeScriptAngularBuildES6PestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch ES6 Petstore Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + integration-test + + exec + + + npm + + install + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + diff --git a/CI/samples.ci/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml b/CI/samples.ci/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml new file mode 100644 index 000000000000..339fe7665186 --- /dev/null +++ b/CI/samples.ci/client/petstore/typescript-fetch/builds/with-npm-version/pom.xml @@ -0,0 +1,73 @@ + + 4.0.0 + org.openapitools + TypeScriptAngularBuildWithNPMVersionPestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch Petstore Client (with npm) + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + integration-test + + exec + + + npm + + install + + + + + npm-build + integration-test + + exec + + + npm + + run + build + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + diff --git a/CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml b/CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml new file mode 100644 index 000000000000..92063ea7bcc5 --- /dev/null +++ b/CI/samples.ci/client/petstore/typescript-fetch/tests/default/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + org.openapitools + TypeScriptFetchPestoreClientTests + pom + 1.0-SNAPSHOT + TS Fetch Petstore Test Client + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory} + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + npm-install + pre-integration-test + + exec + + + npm + + install + + + + + npm-test + integration-test + + exec + + + npm + + test + + + + + + + + diff --git a/CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/obj/Debug/Org.OpenAPITools.Test.csproj.CoreCompileInputs.cache b/CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/obj/Debug/Org.OpenAPITools.Test.csproj.CoreCompileInputs.cache new file mode 100644 index 000000000000..4096123585d5 --- /dev/null +++ b/CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/obj/Debug/Org.OpenAPITools.Test.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +c2fcc2ae9693a8e8d02b25e286844aad88188fcb diff --git a/CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/obj/Debug/Org.OpenAPITools.Test.csprojResolveAssemblyReference.cache b/CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/obj/Debug/Org.OpenAPITools.Test.csprojResolveAssemblyReference.cache new file mode 100644 index 000000000000..76cdea6cfa73 Binary files /dev/null and b/CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/obj/Debug/Org.OpenAPITools.Test.csprojResolveAssemblyReference.cache differ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fe33fdcb1ea6..50906d89978e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,6 +12,7 @@ - Search the [open issue](https://github.com/openapitools/openapi-generator/issues) to ensure no one else has reported something similar and no one is actively working on similar proposed change. - If no one has suggested something similar, open an ["issue"](https://github.com/openapitools/openapi-generator/issues) with your suggestion to gather feedback from the community. + - If you're adding a new option to a generator, please consider using the `-t` option with customized templates instead or start a discussion first by opening an issue as we want to avoid adding too many options to the generator. - It's recommended to **create a new git branch** for the change so that the merge commit message looks nicer in the commit history. ## How to contribute @@ -82,10 +83,11 @@ For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master To add test cases (optional) covering the change in the code generator, please refer to [modules/openapi-generator/src/test/java/org/openapitools/codegen](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/test/java/org/openapitools/codegen) To test the templates, please perform the following: -- Update the Petstore sample by running the shell script under `bin` folder. For example, run `./bin/ruby-petstore.sh` to update the Ruby PetStore API client under [`samples/client/petstore/ruby`](https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/ruby) For Windows, the batch files can be found under `bin\windows` folder. (If you find that there are new files generated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec from time to time. If you've questions or concerns, please open a ticket to start a discussion) +- Update the Petstore sample by running the shell script under `bin` folder. For example, run `./bin/ruby-client-petstore.sh` to update the Ruby PetStore API client under [`samples/client/petstore/ruby`](https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/ruby) For Windows, the batch files can be found under `bin\windows` folder. (If you find that there are new files generated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec from time to time. If you've questions or concerns, please open a ticket to start a discussion) - Run the tests in the sample folder, e.g. in `samples/client/petstore/ruby`, run `mvn integration-test -rf :RubyPetstoreClientTests`. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests) - Finally, git commit the updated samples files: `git commit -a` (`git add -A` if added files with new test cases) +- For new test cases, please add to the [Fake Petstore spec](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml) To start the CI tests, you can run `mvn verify -Psamples` (assuming you've all the required tools installed to run tests for different languages) or you can leverage http://travis-ci.org to run the CI tests by adding your own openapi-generator repository. diff --git a/README.md b/README.md index 45f98af85527..6a97d14dc89b 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,11 @@
-[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`3.2.2`): [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/master.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator) +[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.0.0`): [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/master.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator) [![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator) [![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=master)](https://app.shippable.com/github/OpenAPITools/openapi-generator) [![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu) -[`4.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/4.0.x) branch: [![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/4.0.x.svg?label=Integration%20Test)](https://travis-ci.org/OpenAPITools/openapi-generator) -[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator/tree/4.0.x.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator) -[![Run Status](https://api.shippable.com/projects/5af6bf74e790f4070084a115/badge?branch=4.0.x)](https://app.shippable.com/github/OpenAPITools/openapi-generator) -[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=4.0.x&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
@@ -31,7 +27,7 @@ :notebook_with_decorative_cover: The eBook [A Beginner's Guide to Code Generation for REST APIs](https://gumroad.com/l/swagger_codegen_beginner) is a good starting point for beginners :notebook_with_decorative_cover: -:warning: If the OpenAPI spec is obtained from an untrusted source, please make sure you've reviewed the spec before using OpenAPI Generator to generate the API client, server stub or documentation as [code injection](https://en.wikipedia.org/wiki/Code_injection) may occur :warning: +:warning: If the OpenAPI spec, templates or any input (e.g. options, environment variables) is obtained from an untrusted source or environment, please make sure you've reviewed these inputs before using OpenAPI Generator to generate the API client, server stub or documentation to avoid potential security issues (e.g. [code injection](https://en.wikipedia.org/wiki/Code_injection)) :warning: :bangbang: Both "OpenAPI Tools" (https://OpenAPITools.org - the parent organization of OpenAPI Generator) and "OpenAPI Generator" are not affiliated with OpenAPI Initiative (OAI) :bangbang: @@ -42,11 +38,11 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se | | Languages/Frameworks | |-|-| -**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 6.x), Aurelia, Fetch, Inversify, jQuery, Node) -**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin**, **PHP** (Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), Scalatra) +**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 7.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs) +**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), Scalatra) **API documentation generators** | **HTML**, **Confluence Wiki** **Configuration files** | [**Apache2**](https://httpd.apache.org/) -**Others** | **JMeter** +**Others** | **GraphQL**, **JMeter**, **MySQL Schema** ## Table of contents @@ -60,6 +56,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se - [1.4 - Build Projects](#14---build-projects) - [1.5 - Homebrew](#15---homebrew) - [1.6 - Docker](#16---docker) + - [1.7 - NPM](#17---npm) - [2 - Getting Started](#2---getting-started) - [3 - Usage](#3---usage) - [3.1 - Customization](#31---customization) @@ -82,10 +79,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20 OpenAPI Generator Version | Release Date | Notes ---------------------------- | ------------ | ----- -4.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/)| TBD | Major release with breaking changes (no fallback) -3.3.0 (upcoming minor release)| TBD | Minor release (breaking changes with fallbacks) -3.2.2 (current master, upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.2.2-SNAPSHOT/)| TBD | Bugfix release -[3.2.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.2.1) (latest stable release) | 14.08.2018 | Bugfix release +4.0.0 (upcoming release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/)| 20.12.2018 | Major release with breaking changes (with or without fallback) +[3.3.4](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.3.4) (latest stable release) | 30.11.2018 | Bugfix release OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0 @@ -93,7 +88,7 @@ For old releases, please refer to the [**Release**](https://github.com/OpenAPITo ## [1.2 - Artifacts on Maven Central](#table-of-contents) -You can find our released artefacts on maven central: +You can find our released artifacts on maven central: **Core:** ```xml @@ -141,16 +136,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository. If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum): -JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.2.1/openapi-generator-cli-3.2.1.jar` +JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.3.4/openapi-generator-cli-3.3.4.jar` For **Mac/Linux** users: ```sh -wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.2.1/openapi-generator-cli-3.2.1.jar -O openapi-generator-cli.jar +wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.3.4/openapi-generator-cli-3.3.4.jar -O openapi-generator-cli.jar ``` For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g. ``` -Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.2.1/openapi-generator-cli-3.2.1.jar +Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.3.4/openapi-generator-cli-3.3.4.jar ``` After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage. @@ -163,7 +158,7 @@ export PATH=${JAVA_HOME}/bin:$PATH ### Launcher Script -One downside to manual jar downloads is that you don't keep up-to-date with the latest released version. We have a Bash launcher script at [bin/utils/openapi-generator.cli.sh](./bin/utils/openapi-generator.cli.sh) which resolves this issue. +One downside to manual jar downloads is that you don't keep up-to-date with the latest released version. We have a Bash launcher script at [bin/utils/openapi-generator.cli.sh](./bin/utils/openapi-generator-cli.sh) which resolves this issue. To install the launcher script, copy the contents of the script to a location on your path and make the script executable. @@ -210,7 +205,7 @@ To build from source, you need the following installed and available in your `$P * [Java 8](http://java.oracle.com) -* [Apache maven 3.3.3 or greater](http://maven.apache.org/) +* [Apache maven 3.3.4 or greater](http://maven.apache.org/) After cloning the project, you can build it from source with this command: ```sh @@ -279,13 +274,13 @@ GEN_IP=$(docker inspect --format '{{.NetworkSettings.IPAddress}}' $CID) -d '{"openAPIUrl": "https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml"}' \ 'http://localhost:8888/api/gen/clients/ruby' -{"code":"c2d483d3-3672-40e9-91df-b9ffd18d22b8","link":"http://localhost:8888/api/gen/download/c2d483d3-3672-40e9-91df-b9ffd18d22b8"} +{"code":"c2d483.3.4672-40e9-91df-b9ffd18d22b8","link":"http://localhost:8888/api/gen/download/c2d483.3.4672-40e9-91df-b9ffd18d22b8"} # Download the generated zip file -> wget http://localhost:8888/api/gen/download/c2d483d3-3672-40e9-91df-b9ffd18d22b8 +> wget http://localhost:8888/api/gen/download/c2d483.3.4672-40e9-91df-b9ffd18d22b8 # Unzip the file -> unzip c2d483d3-3672-40e9-91df-b9ffd18d22b8 +> unzip c2d483.3.4672-40e9-91df-b9ffd18d22b8 # Shutdown the openapi generator image > docker stop $CID && docker rm $CID @@ -341,6 +336,30 @@ cd /vagrant ./run-in-docker.sh mvn package ``` +### [1.7 - NPM](#table-of-contents) + +There is also an [NPM package wrapper](https://www.npmjs.com/package/@openapitools/openapi-generator-cli) available for different platforms (e.g. Linux, Mac, Windows). (JVM is still required) +Please see the [project's README](https://github.com/openapitools/openapi-generator-cli) there for more information. + +Install it globally to get the CLI available on the command line: + +```sh +npm install @openapitools/openapi-generator-cli -g +openapi-generator version +``` + +Or install a particualar OpenAPI Generator version (e.g. v3.3.4): + +```sh +npm install @openapitools/openapi-generator-cli@cli-3.3.4 -g +``` + +Or install it as dev-dependency: + +```sh +npm install @openapitools/openapi-generator-cli -D +``` + ## [2 - Getting Started](#table-of-contents) To generate a PHP client for [petstore.yaml](https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml), please run the following @@ -355,7 +374,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat ``` (if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php -o c:\temp\php_api_client`) -You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.0.0/openapi-generator-cli-3.0.0.jar) +You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.3.4/openapi-generator-cli-3.3.4.jar) To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate` @@ -367,21 +386,23 @@ To get a list of PHP specified options (which can be passed to the generator wit You can build a client against the [Petstore API](https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml) as follows: ```sh -./bin/java-petstore.sh +./bin/java-petstore-okhttp-gson.sh ``` -(On Windows, run `.\bin\windows\java-petstore.bat` instead) +(On Windows, run `.\bin\windows\java-petstore-okhttp-gson.bat` instead) -This will run the generator with this command: +This script uses the default library, which is `okhttp-gson`. It will run the generator with this command: ```sh java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \ -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml \ -g java \ - -o samples/client/petstore/java + -o samples/client/petstore/java/okhttp-gson ``` -with a number of options. You can get the options with the `help generate` command (below only shows partial results): +with a number of options. [The java options are documented here.](docs/generators/java.md) + +You can also get the options with the `help generate` command (below only shows partial results): ``` NAME @@ -404,15 +425,15 @@ SYNOPSIS [--import-mappings ...] [--instantiation-types ...] [--invoker-package ] - [(-l | --lang )] [--language-specific-primitives ...] - [--library ] [--model-name-prefix ] + [--library ] [--log-to-stderr] + [--model-name-prefix ] [--model-name-suffix ] [--model-package ] [(-o | --output )] [--release-note ] [--remove-operation-id-prefix] [--reserved-words-mappings ...] - [(-s | --skip-overwrite)] + [(-s | --skip-overwrite)] [--skip-validate-spec] [(-t