Feedback
This commit is contained in:
Родитель
ac9a9cf6f5
Коммит
70327dce09
|
@ -536,7 +536,9 @@ class SpecResolver {
|
|||
for (let statusCode in operation.responses) {
|
||||
let response = operation.responses[statusCode];
|
||||
if (response.schema) {
|
||||
response.schema = utils.relaxModelLikeEntities(response.schema);
|
||||
if (operation.produces != 'application/octet-stream') {
|
||||
response.schema = utils.relaxModelLikeEntities(response.schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
"application/json"
|
||||
],
|
||||
"paths": {
|
||||
"/open": {
|
||||
"/open/object": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Content"
|
||||
],
|
||||
"operationId": "Content_Produce",
|
||||
"operationId": "Content_ProduceTypeObject",
|
||||
"description": "Operation to test produce application/octet-stream",
|
||||
"x-ms-examples": {
|
||||
"Downloads stream": {
|
||||
|
@ -41,7 +41,58 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/append": {
|
||||
"/open/file": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Content"
|
||||
],
|
||||
"operationId": "Content_ProduceTypeFile",
|
||||
"description": "Operation to test produce application/octet-stream",
|
||||
"x-ms-examples": {
|
||||
"Downloads stream": {
|
||||
"$ref": "./examples/download.json"
|
||||
}
|
||||
},
|
||||
"produces": [
|
||||
"application/octet-stream"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/open/object/file": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Content"
|
||||
],
|
||||
"operationId": "Content_ProduceTypeObjectFormatFile",
|
||||
"description": "Operation to test produce application/octet-stream",
|
||||
"x-ms-examples": {
|
||||
"Downloads stream": {
|
||||
"$ref": "./examples/download.json"
|
||||
}
|
||||
},
|
||||
"produces": [
|
||||
"application/octet-stream"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"format": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/append/object": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Content"
|
||||
|
@ -49,7 +100,73 @@
|
|||
"consumes": [
|
||||
"application/octet-stream"
|
||||
],
|
||||
"operationId": "Content_Consume",
|
||||
"operationId": "Content_ConsumeTypeObject",
|
||||
"description": "Operation to test consume application/octet-stream",
|
||||
"x-ms-examples": {
|
||||
"Uploads stream": {
|
||||
"$ref": "./examples/upload.json"
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "streamContents",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object"
|
||||
},
|
||||
"required": true,
|
||||
"description": "Stream parameter description"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/append/file": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Content"
|
||||
],
|
||||
"consumes": [
|
||||
"application/octet-stream"
|
||||
],
|
||||
"operationId": "Content_ConsumeTypeFile",
|
||||
"description": "Operation to test consume application/octet-stream",
|
||||
"x-ms-examples": {
|
||||
"Uploads stream": {
|
||||
"$ref": "./examples/upload.json"
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "streamContents",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
},
|
||||
"required": true,
|
||||
"description": "Stream parameter description"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/append/object/file": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Content"
|
||||
],
|
||||
"consumes": [
|
||||
"application/octet-stream"
|
||||
],
|
||||
"operationId": "Content_ConsumeTypeObjectFormatFile",
|
||||
"description": "Operation to test consume application/octet-stream",
|
||||
"x-ms-examples": {
|
||||
"Uploads stream": {
|
||||
|
|
|
@ -121,23 +121,16 @@
|
|||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "ResponseFilter",
|
||||
"name": "srs",
|
||||
"in": "query",
|
||||
"description": "A comma-delimited list of answers to include in the response. If you do not specify this parameter, the response includes all search answers for which there's relevant data.",
|
||||
"required": false,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Entities",
|
||||
"Places"
|
||||
],
|
||||
"x-ms-enum": {
|
||||
"name": "AnswerType",
|
||||
"modelAsString": false
|
||||
}
|
||||
},
|
||||
"collectionFormat": "csv"
|
||||
"description": "Projection used in describing the bbox",
|
||||
"required": true,
|
||||
"default": "EPSG:4326",
|
||||
"enum": [
|
||||
"EPSG:4326",
|
||||
"EPSG:3857"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "ResponseFormat",
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
{
|
||||
"parameters": {
|
||||
"Ocp-Apim-Subscription-Key": "{API key}",
|
||||
"q": "tom cruise"
|
||||
"q": "tom cruise",
|
||||
"SafeSearch": "Strict",
|
||||
"srs": "EPSG:4326"
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
|
|
|
@ -311,32 +311,14 @@ describe('Model Validation', function () {
|
|||
describe('Content type - ', function () {
|
||||
it('should pass for consumes application/octet-stream', function (done) {
|
||||
let specPath = `${__dirname}/modelValidation/swaggers/specification/contenttype/datalake.json`;
|
||||
let operationIds = "Content_Consume";
|
||||
validate.validateExamples(specPath, operationIds, { consoleLogLevel: 'off' }).then((result) => {
|
||||
assert(result.validityStatus === true, `swagger "${specPath}" with operation "${operationIds}" contains model validation errors.`);
|
||||
validate.validateExamples(specPath, undefined, { consoleLogLevel: 'off' }).then((result) => {
|
||||
console.dir(result, { depth: null });
|
||||
assert(result.validityStatus === true, `swagger "${specPath}" contains model validation errors.`);
|
||||
console.log(result);
|
||||
done();
|
||||
}).catch((err) => {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail for invalid type response in produces application/octet-stream', function (done) {
|
||||
let specPath = `${__dirname}/modelValidation/swaggers/specification/contenttype/datalake.json`;
|
||||
let operationIds = "Content_Produce";
|
||||
validate.validateExamples(specPath, operationIds, { consoleLogLevel: 'off' }).then((result) => {
|
||||
assert(result.validityStatus === false, `swagger "${specPath}" with operation "${operationIds}" contains passed incorrectly.`);
|
||||
console.log(result);
|
||||
done();
|
||||
}).catch((err) => {
|
||||
try {
|
||||
assert.equal(err.code, 'INVALID_RESPONSE_BODY');
|
||||
assert.equal(err.innerErrors[0].code, 'INVALID_TYPE');
|
||||
done();
|
||||
} catch (er) {
|
||||
done(er);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Загрузка…
Ссылка в новой задаче