embraser01 / typoas Goto Github PK
View Code? Open in Web Editor NEWOpen API (OAS 3.0) Typescript generator
License: MIT License
Open API (OAS 3.0) Typescript generator
License: MIT License
when a param name (in this case query param) contains square brackets, it ends up generating types like this:
{
page[number]?: number;
page[size]?: number;
filter[search]?: string;
}
which is invalid TS. they need to be quoted. this style of query param is standard for JSONAPI
I tried to run the CLI with npx @typoas/cli generate
but it looks like it's trying to run the CLI as a shell script.
.npm/bin/cli: line 1: use strict: command not found
.npm/bin/cli: line 2: syntax error near unexpected token `exports,'
.npm/bin/cli: line 2: `Object.defineProperty(exports, "__esModule", { value: true });'
After manually adding a shebang like this it works:
#!/usr/bin/env node
Is this not the expected usage? Or maybe this is a yarn vs npm difference?
Hi there great tool, but the documentation and examples for variableConfiguration are a bit limited:
Can you add Documentation about Auth, Headers etc?
Thanks.
ESM Target
CJS Target
For bundling, let's go with esbuild
Info: Generating spec 'qBittorrent WebUI API'
Internal Error: Debug Failure. False expression: Negative numbers should be created in combination with createPrefixUnaryExpression
at Object.createNumericLiteral (C:\Users\marca\AppData\Local\Temp\xfs-c80c06f2\dlx-24264\node_modules\typescript\lib\typescript.js:24871:11)
at C:\Users\marca\AppData\Local\Temp\xfs-c80c06f2\dlx-24264\node_modules\@typoas\generator\lib\generator\utils\types.js:44:45
at Array.map (<anonymous>)
at createTypeFromSchema (C:\Users\marca\AppData\Local\Temp\xfs-c80c06f2\dlx-24264\node_modules\@typoas\generator\lib\generator\utils\types.js:37:14)
at C:\Users\marca\AppData\Local\Temp\xfs-c80c06f2\dlx-24264\node_modules\@typoas\generator\lib\generator\utils\types.js:92:104
at Array.map (<anonymous>)
at createTypeFromSchema (C:\Users\marca\AppData\Local\Temp\xfs-c80c06f2\dlx-24264\node_modules\@typoas\generator\lib\generator\utils\types.js:86:55)
at C:\Users\marca\AppData\Local\Temp\xfs-c80c06f2\dlx-24264\node_modules\@typoas\generator\lib\index.js:24:282
at Array.map (<anonymous>)
at createSchemaComponents (C:\Users\marca\AppData\Local\Temp\xfs-c80c06f2\dlx-24264\node_modules\@typoas\generator\lib\index.js:18:36)
It would replace move to schemas components that are equivalent
Client should handle timeout
(number in ms) to override default browser timeout behavior.
Doing it with axios is quite easy :
resp = await axiosClient.request({
url: request.getUrl(),
method: request.getHttpMethod() as Method,
headers: request.getHeaders(),
data: request.getBody(),
timeout: 3000 // will abort promise if it takes more than 3 sec
});
I don't know how to do it so far in generated client. I guess a good place would be to put it in RequestContext
. The tricky part is to be able to override it in the generated api functions.
The idea would be to generate the x-codeSamples
field for operations directly from typoas
Ref: https://redocly.com/docs/api-reference-docs/specification-extensions/x-code-samples/
typoas/packages/typoas-runtime/src/context/index.ts
Lines 82 to 85 in 81b9f88
Based on my understanding of how browsers handle FormData, we want to make sure that this is NOT set so that the correct header can be added automatically right?
See MDN FormData: https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects#sect4
Currently $ref
only support relative schemas (schemas declared in the same file).
It should support local and http files
Existing work: https://www.npmjs.com/package/@openapi-generator-plus/json-schema-ref-parser
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.