Skip to content

Commit 00a7456

Browse files
authored
Fix formatting using already-configured formatter (#86)
* Fix formatting using already-configured formatter - We already have a formatter set up, but it is not being used - Run npm run format on the entire repo - Add .vscode to gitignore - There should be no functional changes in this PR * Fix broken tests - Add extra URL flag which was missing from expected value --------- Co-authored-by: Rifdhan Nazeer <rifdhan.nazeer@thoughtspot.com>
1 parent 7a69a23 commit 00a7456

43 files changed

Lines changed: 12622 additions & 11183 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ dist
125125
# TernJS port file
126126
.tern-port
127127

128+
# VSCode config
129+
.vscode
130+
128131
# Stores VSCode versions used for testing VSCode extensions
129132
.vscode-test
130133

biome.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
2-
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3-
"organizeImports": {
4-
"enabled": true
5-
},
6-
"files": {
7-
"include": ["src/**/*.ts", "test/**/*.ts"]
8-
},
9-
"linter": {
10-
"enabled": true,
11-
"rules": {
12-
"suspicious": {
13-
"noExplicitAny": "off"
14-
},
15-
"style": {
16-
"noNonNullAssertion": "off",
17-
"noParameterAssign": "off"
18-
}
19-
}
20-
},
21-
"formatter": {
22-
"enabled": true,
23-
"include": ["src/**/*.ts", "test/**/*.ts"]
24-
}
25-
}
2+
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"files": {
7+
"include": ["src/**/*.ts", "test/**/*.ts"]
8+
},
9+
"linter": {
10+
"enabled": true,
11+
"rules": {
12+
"suspicious": {
13+
"noExplicitAny": "off"
14+
},
15+
"style": {
16+
"noNonNullAssertion": "off",
17+
"noParameterAssign": "off"
18+
}
19+
}
20+
},
21+
"formatter": {
22+
"enabled": true,
23+
"include": ["src/**/*.ts", "test/**/*.ts"]
24+
}
25+
}

src/api-schemas/open-api-spec.ts

Lines changed: 149 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,170 @@
1-
import { Hono } from 'hono';
2-
import { toolDefinitionsMCPServer } from '../servers/mcp-server';
3-
import { capitalize } from '../utils';
1+
import { Hono } from "hono";
2+
import { toolDefinitionsMCPServer } from "../servers/mcp-server";
3+
import { capitalize } from "../utils";
44

55
export const openApiSpecHandler = new Hono();
66

77
// Helper function to generate tool schema
8-
const generateToolSchema = (tool: typeof toolDefinitionsMCPServer[0]) => {
9-
const schemaName = `${capitalize(tool.name)}Request`;
10-
const generatedSchema = { ...tool.inputSchema } as any;
11-
generatedSchema.$schema = undefined;
12-
return { schemaName, schema: generatedSchema };
8+
const generateToolSchema = (tool: (typeof toolDefinitionsMCPServer)[0]) => {
9+
const schemaName = `${capitalize(tool.name)}Request`;
10+
const generatedSchema = { ...tool.inputSchema } as any;
11+
generatedSchema.$schema = undefined;
12+
return { schemaName, schema: generatedSchema };
1313
};
1414

1515
// Helper function to generate response schema
1616
const generateResponseSchema = () => {
17-
return {
18-
type: 'object',
19-
description: 'Response from the API endpoint'
20-
};
17+
return {
18+
type: "object",
19+
description: "Response from the API endpoint",
20+
};
2121
};
2222

2323
// Create individual endpoints for each tool
2424
for (const tool of toolDefinitionsMCPServer) {
25-
const { schemaName, schema } = generateToolSchema(tool);
26-
const responseSchema = generateResponseSchema();
25+
const { schemaName, schema } = generateToolSchema(tool);
26+
const responseSchema = generateResponseSchema();
2727

28-
openApiSpecHandler.get(`/tools/${tool.name}`, async (c) => {
29-
const toolSpec = {
30-
openapi: '3.0.0',
31-
info: {
32-
title: 'ThoughtSpot API',
33-
version: '1.0.0',
34-
description: 'API for interacting with ThoughtSpot services'
35-
},
36-
servers: [
37-
{
38-
url: '<TS_AGENT_URL>',
39-
description: 'ThoughtSpot agent url'
40-
}
41-
],
42-
paths: {
43-
[`/api/tools/${tool.name}`]: {
44-
post: {
45-
summary: tool.description,
46-
description: tool.description,
47-
operationId: tool.name,
48-
tags: ['Tools'],
49-
requestBody: {
50-
required: true,
51-
content: {
52-
'application/json': {
53-
schema: {
54-
$ref: `#/components/schemas/${schemaName}`
55-
}
56-
}
57-
}
58-
},
59-
responses: {
60-
'200': {
61-
description: 'Successful response',
62-
content: {
63-
'application/json': {
64-
schema: {
65-
$ref: `#/components/schemas/${capitalize(tool.name)}Response`
66-
}
67-
}
68-
}
69-
},
70-
'400': {
71-
description: 'Bad request - Invalid input parameters'
72-
},
73-
'401': {
74-
description: 'Unauthorized - Invalid or missing authentication'
75-
},
76-
'500': {
77-
description: 'Internal server error'
78-
}
79-
}
80-
}
81-
}
82-
},
83-
components: {
84-
schemas: {
85-
[schemaName]: schema,
86-
[`${capitalize(tool.name)}Response`]: responseSchema
87-
}
88-
}
89-
};
28+
openApiSpecHandler.get(`/tools/${tool.name}`, async (c) => {
29+
const toolSpec = {
30+
openapi: "3.0.0",
31+
info: {
32+
title: "ThoughtSpot API",
33+
version: "1.0.0",
34+
description: "API for interacting with ThoughtSpot services",
35+
},
36+
servers: [
37+
{
38+
url: "<TS_AGENT_URL>",
39+
description: "ThoughtSpot agent url",
40+
},
41+
],
42+
paths: {
43+
[`/api/tools/${tool.name}`]: {
44+
post: {
45+
summary: tool.description,
46+
description: tool.description,
47+
operationId: tool.name,
48+
tags: ["Tools"],
49+
requestBody: {
50+
required: true,
51+
content: {
52+
"application/json": {
53+
schema: {
54+
$ref: `#/components/schemas/${schemaName}`,
55+
},
56+
},
57+
},
58+
},
59+
responses: {
60+
"200": {
61+
description: "Successful response",
62+
content: {
63+
"application/json": {
64+
schema: {
65+
$ref: `#/components/schemas/${capitalize(tool.name)}Response`,
66+
},
67+
},
68+
},
69+
},
70+
"400": {
71+
description: "Bad request - Invalid input parameters",
72+
},
73+
"401": {
74+
description: "Unauthorized - Invalid or missing authentication",
75+
},
76+
"500": {
77+
description: "Internal server error",
78+
},
79+
},
80+
},
81+
},
82+
},
83+
components: {
84+
schemas: {
85+
[schemaName]: schema,
86+
[`${capitalize(tool.name)}Response`]: responseSchema,
87+
},
88+
},
89+
};
9090

91-
return c.json(toolSpec);
92-
});
91+
return c.json(toolSpec);
92+
});
9393
}
9494

9595
// Main OpenAPI spec endpoint that combines all tools
96-
openApiSpecHandler.get('/', async (c) => {
97-
const paths: Record<string, any> = {};
98-
const schemas: Record<string, any> = {};
96+
openApiSpecHandler.get("/", async (c) => {
97+
const paths: Record<string, any> = {};
98+
const schemas: Record<string, any> = {};
9999

100-
// any tool added to the toolDefinitionsMCPServer will be added to the openapi spec automatically
101-
// the api server path should be /api/tools/<tool-name>
102-
for (const tool of toolDefinitionsMCPServer) {
103-
const { schemaName, schema } = generateToolSchema(tool);
104-
const responseSchema = generateResponseSchema();
100+
// any tool added to the toolDefinitionsMCPServer will be added to the openapi spec automatically
101+
// the api server path should be /api/tools/<tool-name>
102+
for (const tool of toolDefinitionsMCPServer) {
103+
const { schemaName, schema } = generateToolSchema(tool);
104+
const responseSchema = generateResponseSchema();
105105

106-
schemas[schemaName] = schema;
107-
schemas[`${capitalize(tool.name)}Response`] = responseSchema;
108-
109-
paths[`/api/tools/${tool.name}`] = {
110-
post: {
111-
summary: tool.description,
112-
description: tool.description,
113-
operationId: tool.name,
114-
tags: ['Tools'],
115-
requestBody: {
116-
required: true,
117-
content: {
118-
'application/json': {
119-
schema: {
120-
$ref: `#/components/schemas/${schemaName}`
121-
}
122-
}
123-
}
124-
},
125-
responses: {
126-
'200': {
127-
description: 'Successful response',
128-
content: {
129-
'application/json': {
130-
schema: {
131-
$ref: `#/components/schemas/${capitalize(tool.name)}Response`
132-
}
133-
}
134-
}
135-
},
136-
'400': {
137-
description: 'Bad request - Invalid input parameters'
138-
},
139-
'401': {
140-
description: 'Unauthorized - Invalid or missing authentication'
141-
},
142-
'500': {
143-
description: 'Internal server error'
144-
}
145-
}
146-
}
147-
};
148-
}
106+
schemas[schemaName] = schema;
107+
schemas[`${capitalize(tool.name)}Response`] = responseSchema;
149108

150-
const openApiDocument = {
151-
openapi: '3.0.0',
152-
info: {
153-
title: 'ThoughtSpot API',
154-
version: '1.0.0',
155-
description: 'API for interacting with ThoughtSpot services'
156-
},
157-
servers: [
158-
{
159-
url: '<TS_AGENT_URL>',
160-
description: 'ThoughtSpot agent url'
161-
}
162-
],
163-
paths: paths,
164-
components: {
165-
schemas: schemas
166-
}
167-
};
109+
paths[`/api/tools/${tool.name}`] = {
110+
post: {
111+
summary: tool.description,
112+
description: tool.description,
113+
operationId: tool.name,
114+
tags: ["Tools"],
115+
requestBody: {
116+
required: true,
117+
content: {
118+
"application/json": {
119+
schema: {
120+
$ref: `#/components/schemas/${schemaName}`,
121+
},
122+
},
123+
},
124+
},
125+
responses: {
126+
"200": {
127+
description: "Successful response",
128+
content: {
129+
"application/json": {
130+
schema: {
131+
$ref: `#/components/schemas/${capitalize(tool.name)}Response`,
132+
},
133+
},
134+
},
135+
},
136+
"400": {
137+
description: "Bad request - Invalid input parameters",
138+
},
139+
"401": {
140+
description: "Unauthorized - Invalid or missing authentication",
141+
},
142+
"500": {
143+
description: "Internal server error",
144+
},
145+
},
146+
},
147+
};
148+
}
168149

169-
return c.json(openApiDocument);
170-
});
150+
const openApiDocument = {
151+
openapi: "3.0.0",
152+
info: {
153+
title: "ThoughtSpot API",
154+
version: "1.0.0",
155+
description: "API for interacting with ThoughtSpot services",
156+
},
157+
servers: [
158+
{
159+
url: "<TS_AGENT_URL>",
160+
description: "ThoughtSpot agent url",
161+
},
162+
],
163+
paths: paths,
164+
components: {
165+
schemas: schemas,
166+
},
167+
};
168+
169+
return c.json(openApiDocument);
170+
});

0 commit comments

Comments
 (0)