Skip to content

Commit 634c956

Browse files
committed
fix default Api export to do both default and regular export
1 parent 1c7c155 commit 634c956

File tree

6 files changed

+24
-20
lines changed

6 files changed

+24
-20
lines changed

oxide-api/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

oxide-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@oxide/api",
3-
"version": "0.1.0-alpha.7",
3+
"version": "0.1.0-alpha.8",
44
"description": "TypeScript client for the Oxide API",
55
"engines": {
66
"node": ">=18"

oxide-api/src/Api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4175,7 +4175,7 @@ export type ApiListMethods = Pick<
41754175
>;
41764176

41774177
type EmptyObj = Record<string, never>;
4178-
export default class Api extends HttpClient {
4178+
export class Api extends HttpClient {
41794179
methods = {
41804180
/**
41814181
* Start an OAuth 2.0 Device Authorization Grant
@@ -6990,3 +6990,5 @@ export default class Api extends HttpClient {
69906990
},
69916991
};
69926992
}
6993+
6994+
export default Api;

oxide-openapi-gen-ts/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

oxide-openapi-gen-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@oxide/openapi-gen-ts",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"description": "OpenAPI client generator used to generate Oxide TypeScript SDK",
55
"keywords": [
66
"oxide",

oxide-openapi-gen-ts/src/client/api.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function checkErrorSchema(schema: Schema) {
5555
},
5656
required: ["message", "request_id"],
5757
},
58-
"Error schema does not match the one hard-coded as ErrorBody in http-client.ts."
58+
"Error schema does not match the one hard-coded as ErrorBody in http-client.ts.",
5959
);
6060
}
6161

@@ -162,7 +162,7 @@ export function generateApi(spec: OpenAPIV3.Document, destDir: string) {
162162
.map((handlers) =>
163163
Object.entries(handlers!)
164164
.filter(([method]) => method.toUpperCase() in HttpMethods)
165-
.map(([_, conf]) => conf)
165+
.map(([_, conf]) => conf),
166166
)
167167
.flat()
168168
.filter((handler) => {
@@ -173,7 +173,7 @@ export function generateApi(spec: OpenAPIV3.Document, destDir: string) {
173173

174174
// TODO: Fix this type
175175
const ops = operations as Exclude<
176-
typeof operations[number],
176+
(typeof operations)[number],
177177
| string
178178
| (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[]
179179
| OpenAPIV3.ServerObject[]
@@ -182,32 +182,32 @@ export function generateApi(spec: OpenAPIV3.Document, destDir: string) {
182182
const idRoutes = ops.filter((op) => op.operationId?.endsWith("view_by_id"));
183183
if (idRoutes.length > 0) {
184184
w(
185-
"export type ApiViewByIdMethods = Pick<InstanceType<typeof Api>['methods'], "
185+
"export type ApiViewByIdMethods = Pick<InstanceType<typeof Api>['methods'], ",
186186
);
187187
w0(
188188
`${idRoutes
189189
.map((op) => `'${snakeToCamel(op.operationId!)}'`)
190-
.join(" | ")}`
190+
.join(" | ")}`,
191191
);
192192
w(">\n");
193193
}
194194

195195
const listRoutes = ops.filter((op) => op.operationId?.match(/_list(_v1)?$/));
196196
if (listRoutes.length > 0) {
197197
w(
198-
"export type ApiListMethods = Pick<InstanceType<typeof Api>['methods'], "
198+
"export type ApiListMethods = Pick<InstanceType<typeof Api>['methods'], ",
199199
);
200200
w0(
201201
`${listRoutes
202202
.map((op) => `'${snakeToCamel(op.operationId!)}'`)
203-
.join(" | ")}`
203+
.join(" | ")}`,
204204
);
205205
w(">\n");
206206
}
207207

208208
w("type EmptyObj = Record<string, never>;");
209209

210-
w(`export default class Api extends HttpClient {
210+
w(`export class Api extends HttpClient {
211211
methods = {`);
212212

213213
for (const { conf, opId, method, path } of iterPathConfig(spec.paths)) {
@@ -219,10 +219,10 @@ export function generateApi(spec: OpenAPIV3.Document, destDir: string) {
219219

220220
const params = conf.parameters || [];
221221
const pathParams = params.filter(
222-
(p) => "in" in p && p.in === "path"
222+
(p) => "in" in p && p.in === "path",
223223
) as OpenAPIV3.ParameterObject[];
224224
const queryParams = params.filter(
225-
(p) => "in" in p && p.in === "query"
225+
(p) => "in" in p && p.in === "query",
226226
) as OpenAPIV3.ParameterObject[];
227227

228228
const bodyType = contentRef(conf.requestBody);
@@ -294,10 +294,10 @@ export function generateApi(spec: OpenAPIV3.Document, destDir: string) {
294294

295295
const params = conf.parameters || [];
296296
const pathParams = params.filter(
297-
(p) => "in" in p && p.in === "path"
297+
(p) => "in" in p && p.in === "path",
298298
) as OpenAPIV3.ParameterObject[];
299299
const queryParams = params.filter(
300-
(p) => "in" in p && p.in === "query"
300+
(p) => "in" in p && p.in === "query",
301301
) as OpenAPIV3.ParameterObject[];
302302

303303
docComment(conf.summary || conf.description, schemaNames, io);
@@ -331,6 +331,8 @@ export function generateApi(spec: OpenAPIV3.Document, destDir: string) {
331331
}
332332

333333
w(` }
334-
}`);
334+
}
335+
336+
export default Api;`);
335337
out.end();
336338
}

0 commit comments

Comments
 (0)