Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Documentation on how to use the generated client #12069

Unanswered
idc77 asked this question in Q&A
Discussion options

I have generated a client from a spec that a server provided.
I chose typescript-angular client.
How do I actually use it?

Is there any documentation?

You must be logged in to vote

Replies: 1 comment

Comment options

With angular you'll typically import the api module to your module, which will give you access to the different api services within that module. Then through DI you can access them in your different components or services.
Note - make sure you're using the correct angular version, the first one is the now defunct AngularJs, Angular2 means any version of angular since v2.
I haven't used this specific library for the angular client, but the code generated from the swagger web editor would be extracted from the zip into a folder in my repo, my main app module would import ApiModule.forRoot(apiConfig) where apiConfig would be a configuration factory that returns a Configuration object.
After this I could just include something like private fooService: FooService in any component within that module.

With standalone it was a little different, in the ApplicationConfig options of the bootstrapApplication function you add a provider for Configuration like so:
{ provide: Configuration, useFactory: () => new Configuration({ withCredentials: true }), },
Same thing for the BASE_PATH, then in whatever component needs access to the API client you can import the api module that the code generates and use DI to get the relevant service via the constructor again.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /