Skip to content

Commit

Permalink
bump: Update swagger-client to stop using lodash-compat (microsoft#4604)
Browse files Browse the repository at this point in the history
* update swagger-client to stop using lodash-compat

* fix async methods
  • Loading branch information
JhontSouth authored Jan 24, 2024
1 parent 23c16dc commit 05ca65f
Show file tree
Hide file tree
Showing 4 changed files with 704 additions and 85 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"**/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",
"follow-redirects": "^1.14.8"
"follow-redirects": "^1.14.8",
"@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
32 changes: 19 additions & 13 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({
await client.apis.Conversations.Conversations_PostMessage({
conversationId: conversationId,
message: {
from: directLineClientName,
Expand All @@ -46,18 +52,18 @@ async function sendMessage(client, conversationId) {
} while (status == 502);
}

function getMessages(client, conversationId) {
async 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 05ca65f

Please sign in to comment.