diff --git a/.gitignore b/.gitignore index 9cbe992..df923da 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ node_modules .vscode/settings.json .tests/ .lib/ +lib/ diff --git a/copy_swagger.js b/copy_swagger.js new file mode 100644 index 0000000..6275c6b --- /dev/null +++ b/copy_swagger.js @@ -0,0 +1,19 @@ +var exec = require('child_process').exec; +var os = require('os'); + +function puts(error, stdout, stderr) { + if (error) { + console.log(error); + } + console.error(stderr); + console.log(stdout); +} + +if (os.type() === 'Linux') + exec("cp src/api/v2/swagger.yaml lib/src/api/v2/swagger.yaml", puts); +else if (os.type() === 'Darwin') + exec("cp src/api/v2/swagger.yaml lib/src/api/v2/swagger.yaml", puts); +else if (os.type() === 'Windows_NT') + exec("copy src\\api\\v2\\swagger.yaml lib\\src\\api\\v2\\swagger.yaml", puts); +else + throw new Error("Unsupported OS found: " + os.type()); diff --git a/package.json b/package.json index b9c732d..e9621d3 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "preapi-test": "ts-node -r tsconfig-paths/register tests/common/apiTestCaseGenerator.ts -- \"src/api/v2/swagger.yaml\" \".tests/apiTestCase.json\"", "api-test": "mocha -r ts-node/register -r tsconfig-paths/register tests/api_tests/**/*.spec.ts -t 20000", "prebuild": "tslint --config tslint.json --project tsconfig.build.json", - "build": "ttsc -p tsconfig.json" + "build": "ttsc -p tsconfig.json && npm run copy-swagger", + "copy-swagger": "node copy_swagger.js" }, "homepage": "https://github.com/Microsoft/openpaisdk", "repository": { @@ -74,4 +75,4 @@ "bin": { "pai": "lib/src/cli.js" } -} \ No newline at end of file +} diff --git a/src/api/v2/swagger.yaml b/src/api/v2/swagger.yaml index 58c6e0b..44189b7 100644 --- a/src/api/v2/swagger.yaml +++ b/src/api/v2/swagger.yaml @@ -216,7 +216,7 @@ paths: - user - admin '400': - description: NoUserError or IncorrectPassworkError + description: NoUserError or IncorrectPasswordError content: application/json: schema: @@ -1014,7 +1014,7 @@ paths: security: - bearerAuth: [] parameters: - - name: user + - name: username in: query description: filter jobs with username schema: @@ -2017,6 +2017,8 @@ components: - type: object description: other/unknown type properties: {} + readOnly: + type: boolean secretName: type: string mountOptions: @@ -2252,16 +2254,16 @@ components: - email - extension responses: - IncorrectPassworkError: - description: IncorrectPassworkError + IncorrectPasswordError: + description: IncorrectPasswordError content: application/json: schema: $ref: '#/components/schemas/Response' examples: - IncorrectPassworkError: + IncorrectPasswordError: value: - code: IncorrectPassworkError + code: IncorrectPasswordError message: Password is incorrect. NoVirtualClusterError: description: NoVirtualClusterError diff --git a/tests/common/apiTestCases.ts b/tests/common/apiTestCases.ts index 01dcbc2..b7b9c71 100644 --- a/tests/common/apiTestCases.ts +++ b/tests/common/apiTestCases.ts @@ -876,7 +876,10 @@ export const ApiDefaultTestCases: {[key: string]: IApiTestCase} = { type: 'raw', value: 'sdk_test_nonexist_job' } - ] + ], + response: { + statusCode: 404 + } } } ],