Project for my Personal Site
lukeautry / openapi-ts-client-gen Goto Github PK
View Code? Open in Web Editor NEWAn OpenAPI (Swagger) TypeScript client generator
An OpenAPI (Swagger) TypeScript client generator
Project for my Personal Site
Hey, Not sure if I'm doing something wrong. I'm hitting this error:
openapi-ts-client-gen/src/generate-client.ts
Line 310 in 3c17ed0
My swagger spec is v3 and generated using tsoa. Should there be a definitions block?
Given a TypeScript interface:
export interface IManagementFee {
[symbol: string]: number;
}
... which gets generated into this v2 swagger:
"IManagementFee": {
"properties": {},
"type": "object",
"additionalProperties": {
"type": "number",
"format": "double"
}
},
the output is:
export interface IManagementFee {
}
I would expect the output to be the same as the input.
I was looking at this line where you are using a kind of convention where you expect an error body to have status, message and type fields. This is very specific in my opinion.
Instead, could we have the entire response, body and http status into the custom error? Right now I cannot tell if an error was a 400 or a 404, or if in the body I include more information than is currently copied to the error.
I can make a PR if you want me to
By the way nice lib.
Hello, I'm using tsoa in my project and I am in the process of trying to use open-api-ts-client-gen. Thanks for your efforts and work on both projects!
I get an error message when I try to generate client (using CLI version):
$>
node node_modules/openapi-ts-client-gen/dist/cli.js -n Api -f ../path/to/swagger.json -o ./out/swagger.json
Error: no tags for {"get":{"operationId":"getAllUsers","produces":["application/json"],"responses":{"200":{"description":"Ok","schema":{"type":"array","items":{"$ref":"#/definitions/User"}}}},"security":[],"parameters":[]}}
Based on the tsoa README, I get the impression that OperationId
is required for client SDK generation, but not tags. I see in this line that both operationId and tags are required, but a few lines below there is a test to see whether there is a tag at all - which made me raise this question.
Excerpt is included below:
// generate-client.ts
// ...
if (!operation.operationId || !operation.tags) {
throw new Error("no tags for " + JSON.stringify(path));
}
const tag = operation.tags[0];
const service = (serviceMap[tag] = serviceMap[tag] || {
name: `${tag}Service`,
operations: []
});
let operationId = operation.operationId.replace("_", "");
if (tag) {
operationId = operationId.replace(tag, "");
}
// ...
Perhaps I don't have a correct idea of what it is, but I'm assuming it will generate some api models, api calls; or scaffolded code based on the given swagger.json file.
You could put an argument to generate the client without namespaces and try to move away from namespaces, as it seems CRA does not plan to ever support them.
I wanted to generate some clients for my TS code. Unfortunately I couldn't run it. When I run it I get
$ openapi-ts-client-gen
/c/Users/usr/AppData/Roaming/npm/openapi-ts-client-gen: line 1: /node_modules/openapi-ts-client-gen/dist/cli.js: No such file or directory
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.