mirror of
https://github.com/Kong/insomnia.git
synced 2026-10-23 15:19:04 -04:00
Fixed swagger2 importer tests
This commit is contained in:
1 parent
65cd4b0146
commit
be94772382
2 files changed
+4
-10
No files matched your search
@@ -57,7 +57,6 @@
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"authentication": {},
|
||||
"_type": "request",
|
||||
"_id": "addPet"
|
||||
},
|
||||
|
||||
@@ -174,7 +174,7 @@ function importRequest(schema, endpointSchema, globalMimeTypes, id, parentId) {
|
||||
headers: prepareHeaders(endpointSchema),
|
||||
parameters: prepareQueryParams(endpointSchema),
|
||||
};
|
||||
|
||||
|
||||
if (request.body.mimeType && !request.headers.find(header => header.name === 'Content-Type')) {
|
||||
request.headers = [
|
||||
{
|
||||
@@ -183,19 +183,14 @@ function importRequest(schema, endpointSchema, globalMimeTypes, id, parentId) {
|
||||
value: request.body.mimeType,
|
||||
},
|
||||
].concat(request.headers);
|
||||
body: prepareBody(endpointSchema, globalMimeTypes),
|
||||
description: endpointSchema.description,
|
||||
headers: prepareHeaders(endpointSchema),
|
||||
parameters: prepareQueryParams(endpointSchema),
|
||||
};
|
||||
}
|
||||
|
||||
return setupAuthentication(securityDefinitions, endpointSchema, request);
|
||||
return setupAuthentication(schema.securityDefinitions, endpointSchema, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate Insomnia request with authentication
|
||||
*
|
||||
*
|
||||
* @param {Object} securityDefinitions - swagger 2.0 security definitions
|
||||
* @param {Object} endpointSchema - swagger 2.0 endpoint schema
|
||||
* @param {Object} request - insomnia request object
|
||||
@@ -211,7 +206,7 @@ function setupAuthentication(securityDefinitions, endpointSchema, request) {
|
||||
[],
|
||||
);
|
||||
const scopes = endpointSchema.security.reduce((scopes, security) => {
|
||||
for (const defname in security) {
|
||||
for (const defname of Object.keys(security)) {
|
||||
if (security[defname].length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user