psrebniak / swagger-typescript-client-generator Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Allow to overwrite or extend configuration on every fetch call from constructor configuration
const myconfiguration = {}
const client = new MyApiClient({}, requestFactory)
client.getTest(1, myconfiguration)
At the moment only .json files are supported - yaml files should be supported too
by default Object.keys(formData) return empty array so form data is not propagated to final request
It's unclear to me why the client class needs a configuration which extends
{ domain:string }
I think it would be more intuitive if the client config was just extending an object.
Main project should have installed and configured both eslint with typescript support and prettier.
Files should be linted manually and by hook.
Migrate to yarn workspaces and lerna to make exposing additional packages easy
Packages to do:
At the moment default WhatWg.fetch implementation is not exposed - it should be exposed in a separated package
at the moment data rendering is highly coupled with models - need to fix that
eg. for excerpt from attachment I'd expect these generated models:
export type BasicMessage = { preheader: string; subject: string; }
export type Message = { preheader: string; subject: string; id: number; }
example.zip
Hello.
Your tool is really good, moreover it's basically the only tool that allows to generate typescript interface from swagger.json
. But I'd like to migrate to OpenAPI 3.0. Unfortunately the tool currently doesn't understand its format and generate everything as any
.
Would you mind to support that too? I wrote a small generator myself, so it works that way:
function getSwaggerVersion(schema: any): SwaggerVersion {
if (schema.swagger) {
return SwaggerVersion.V2;
}
if (schema.openapi) {
return SwaggerVersion.V3;
}
return SwaggerVersion.Unknown;
}
function getDefinitions(schema: any, swaggerVersion: SwaggerVersion): any {
switch (swaggerVersion) {
case SwaggerVersion.V2:
return schema.definitions;
case SwaggerVersion.V3:
return schema.components.schemas;
default:
throw Error('Unsupported swagger schema');
}
}
So you probably could implement it this way and dynamically determine which schema it is and generate for both v2
and v3
schemas.
Hi,
Thanks for providing this generator, it's great!
However, I have one small issue. It assumes global Response type, which comes from browser Fetch API and which doesn't exist in node.js applications.
I think it would be better to allow generic response type. That way we can use any request factory we like, not necessarily implementing the browser Fetch API Response.
Move tests to jest from mocha
Need to define proper model to decouple internal data and swagger definitions
If schema has missing type but contains one of:
it should be considered as type: object
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.