updated default in swagger and regenerated. added jshint
This commit is contained in:
Родитель
60e77dcf44
Коммит
600f8418f5
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"esversion": 6,
|
||||
"bitwise": true,
|
||||
"camelcase": true,
|
||||
"curly": false,
|
||||
"eqeqeq": false,
|
||||
"forin": true,
|
||||
"immed": true,
|
||||
"indent": 2,
|
||||
"latedef": true,
|
||||
"maxparams": false,
|
||||
"maxdepth": false,
|
||||
"maxstatements": false,
|
||||
"maxcomplexity": false,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"node": true,
|
||||
"noempty": true,
|
||||
"nonew": true,
|
||||
"plusplus": false,
|
||||
"quotmark": "single",
|
||||
"regexp": true,
|
||||
"sub": true,
|
||||
"strict": false,
|
||||
"trailing": true,
|
||||
"undef": true,
|
||||
"unused": false,
|
||||
"shadow": true
|
||||
}
|
|
@ -22,8 +22,8 @@ const mappings = {
|
|||
|
||||
const defaultAutoRestVersion = '1.0.1-20170417-2300-nightly';
|
||||
var usingAutoRestVersion;
|
||||
const specRoot = args['spec-root'] || ".";
|
||||
const project = args['project'];
|
||||
const specRoot = args['spec-root'] || '.';
|
||||
const project = args['project'] || 'testclient';
|
||||
var language = 'NodeJS';
|
||||
var modeler = 'Swagger';
|
||||
|
||||
|
|
23
index.js
23
index.js
|
@ -1,5 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for
|
||||
* license information.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -17,17 +20,17 @@ app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x
|
|||
|
||||
// LiveValidator configuration options
|
||||
const liveValidatorOptions = {
|
||||
"git": {
|
||||
"shouldClone": true,
|
||||
"url": "https://github.com/Azure/azure-rest-api-specs.git"
|
||||
git: {
|
||||
shouldClone: true,
|
||||
url: 'https://github.com/Azure/azure-rest-api-specs.git'
|
||||
}
|
||||
};
|
||||
const validator = new oav.LiveValidator(liveValidatorOptions);
|
||||
validator.initialize().then(() => {
|
||||
console.log("Live validator initialized.");
|
||||
console.log('Live validator initialized.');
|
||||
server = app.listen(port, () => {
|
||||
let host = server.address().address
|
||||
let port = server.address().port
|
||||
let host = server.address().address;
|
||||
let port = server.address().port;
|
||||
|
||||
console.log(`oav - express app listening at http://${host}:${port}`);
|
||||
});
|
||||
|
@ -35,7 +38,7 @@ validator.initialize().then(() => {
|
|||
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Welcome to oav-express');
|
||||
})
|
||||
});
|
||||
|
||||
// This responds a POST request for live validation
|
||||
app.post('/validate', (req, res) => {
|
||||
|
@ -44,7 +47,7 @@ app.post('/validate', (req, res) => {
|
|||
// Something went wrong
|
||||
if (validationResult && validationResult.errors && Array.isArray(validationResult.errors) && validationResult.errors.length) {
|
||||
let errors = validationResult.errors;
|
||||
let is400 = errors.some((error) => { return error.code === ErrorCodes.IncorrectInput });
|
||||
let is400 = errors.some((error) => { return error.code === ErrorCodes.IncorrectInput; });
|
||||
if (is400) {
|
||||
// Return 400 with validationResult
|
||||
return res.send(400, validationResult);
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Describes the error response for negative scenarios.",
|
||||
"description": "Describes the error response for negative scenarios. Currently we return the same schema as 200. The errors array will not be empty.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/LiveValidationError"
|
||||
"$ref": "#/definitions/ValidationResult"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ function _validateRequestResponse(requestResponse, options, callback) {
|
|||
error.message = internalError ? internalError.message : parsedErrorResponse.message;
|
||||
}
|
||||
if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
|
||||
let resultMapper = new client.models['LiveValidationError']().mapper();
|
||||
let resultMapper = new client.models['ValidationResult']().mapper();
|
||||
error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
|
||||
}
|
||||
} catch (defaultError) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче