Git Product home page Git Product logo

typoas's People

Contributors

embraser01 avatar friday avatar github-actions[bot] avatar richardgarnier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

typoas's Issues

incorrect TS generated when param name is like `page[number]`

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

CLI running as shell script instead of nodejs

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?

Handle negative numbers in enum

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)

Running the cli in Windows results in a crash

I ran the following command : npx @typoas/cli generate -i http://localhost:3232/api-json -o dist/client/client.ts

Then, the bin.js script is executed in the windows script host interpreter instead of NodeJS

image

Support timeout option

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.

multipart/form-data Should not be set so the boundry can be set automatically

requestContext.setHeaderParam(
CONTENT_TYPE_HEADER,
'multipart/form-data',
);

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.