Openapi-generator: [typescript-fetch] Documentation / Example Project

Created on 4 Apr 2019  路  10Comments  路  Source: OpenAPITools/openapi-generator

Is there an example or some documentation about the generated typescript-fetch client? I'm really walking around in the dark here. Currently I'm looking at this project for reference.

TypeScript Feature

Most helpful comment

After the refactor was merged in to v4, I feel that a lot has changed. The simple parts of using it as a package or copying the files into your own project haven't changed that much. What's I'd love to see is guidance on consuming the generated clients.

The new Configuration options specifically: oauth, bearer, and middleware. I cannot find examples/guidance on that anywhere.

All 10 comments

馃憤 Thanks for opening this issue!
馃彿 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@GillesWHC Are you looking for documentation on how to use the auto-generated TS fetch client?

@wing328 Yeah that's exaclty what I'm looking for! Setting everything up went great, but actually using the client is a bit harder.

The "web" is very confused about this because of the history of swagger in general. If one wants to consume the result of openapi-generator generate -i ../my-api-spec.json -g typescript-fetch in a "plain" Javascript project, I assume there's a build step. But there is no package.json generated by the generator. What is the workflow to use the client after generation?

@djMax you can copy the generated files into your project and compile them along with the other files of your project. or you can use the npmXXX options to generate a package with a package.json, compile it separately,publish the package into your registry and in your project npm install that package.
See https://openapi-generator.tech/docs/generators/typescript-fetch

@djMax I pushed it to my own npm registry using the --additional-properties npmRepository=YOUR_HOST flag. Then you're able to install it just like any other package using npm. Make sure to configure npm to use your registry instead of the default one!

After the refactor was merged in to v4, I feel that a lot has changed. The simple parts of using it as a package or copying the files into your own project haven't changed that much. What's I'd love to see is guidance on consuming the generated clients.

The new Configuration options specifically: oauth, bearer, and middleware. I cannot find examples/guidance on that anywhere.

As above I've generated my typescript-fetch API and tsc'ed it into a nice npm package - but I can't find a good example of actually calling the library. How should I be building the requestOptions?

Same question. lack of examples here

Any examples? I've switched from swagger-js as its bundle size was ridiculous and have now generated the api.ts file from the codegen editor. It's a Create React App. How should the client be used? More specifically, how do you create the configuration (with a bearerAuth jwt token for each request) and use the generated stub functions? Thanks.

I can see a configuration.ts. I need to be able to use this generated client once the user has successfully logged in via AWS Cognito. Is there an example anywhere?

Was this page helpful?
0 / 5 - 0 ratings