Skip to content

Commit

Permalink
update swagger-client to stop using lodash-compat
Browse files Browse the repository at this point in the history
  • Loading branch information
JhontSouth committed Jan 10, 2024
1 parent 3418fa9 commit 1eb07de
Show file tree
Hide file tree
Showing 4 changed files with 709 additions and 83 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"**/request-promise/tough-cookie": "^4.1.3",
"**/request-promise-native/tough-cookie": "^4.1.3",
"**/istanbul-lib-instrument/@babel/core": "^7.23.2",
"**/@babel/plugin-proposal-class-properties/@babel/core": "^7.23.2"
"**/@babel/plugin-proposal-class-properties/@babel/core": "^7.23.2",
"@types/ramda": "0.26.0"
},
"devDependencies": {
"@azure/logger": "^1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion testing/functional/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Test that hits services",
"main": "",
"dependencies": {
"swagger-client": "^2.1.18"
"swagger-client": "^3.0.0"
},
"directories": {
"test": "tests"
Expand Down
30 changes: 18 additions & 12 deletions testing/functional/tests/directLine.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,31 @@ const userMessage = 'Contoso';
const directLineSecret = process.env.DIRECT_LINE_KEY || null;

const auths = {
AuthorizationBotConnector: new Swagger.ApiKeyAuthorization(
'Authorization',
'BotConnector ' + directLineSecret,
'header'
),
type: 'apiKey',
in: 'header',
name: 'Authorization',
value: 'BotConnector ' + directLineSecret,
};

function getDirectLineClient() {
return new Swagger({
async function getDirectLineClient() {
const client = await Swagger({
spec: directLineSpec,
usePromise: true,
authorizations: auths,
requestInterceptor: (req) => {
if (auths && auths.in === 'header') {
req.headers[auths.name] = auths.value;
}
return req;
},
});

return client;
}

async function sendMessage(client, conversationId) {
let status;
do {
await client.Conversations.Conversations_PostMessage({
return client.apis.Conversations.Conversations_PostMessage({
conversationId: conversationId,
message: {
from: directLineClientName,
Expand All @@ -48,16 +54,16 @@ async function sendMessage(client, conversationId) {

function getMessages(client, conversationId) {
const watermark = null;
return client.Conversations.Conversations_GetMessages({
return client.apis.Conversations.Conversations_GetMessages({
conversationId: conversationId,
watermark: watermark,
}).then((response) => {
return response.obj.messages.filter((message) => message.from !== directLineClientName);
});
}

function getConversationId(client) {
return client.Conversations.Conversations_NewConversation().then((response) => response.obj.conversationId);
async function getConversationId(client) {
return client.apis.Conversations.Conversations_NewConversation().then((response) => response.obj.conversationId);
}

describe('Test Azure Bot', function () {
Expand Down
Loading

0 comments on commit 1eb07de

Please sign in to comment.