Git Product home page Git Product logo

openapi-ts-client-gen's Introduction

openapi-ts-client-gen's People

Contributors

antoniopresto avatar lukeautry avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

openapi-ts-client-gen's Issues

Models with 'additional properties', but no 'properties' produce no output

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.

Store response, http status and body into the custom error

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.

Does every operation require a tag?

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.

CRA TS does not support namespaces

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.

Does this project work?

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

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.