Skip to content

Commit

Permalink
doc and remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp committed Nov 17, 2021
1 parent 78ead4f commit 30fba7a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
12 changes: 0 additions & 12 deletions algolia-typescript-template/models.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,6 @@ export interface Authentication {
applyToRequest(requestOptions: RequestOptions): Promise<void> | void;
}
/*
export class HttpBasicAuth implements Authentication {
public username: string = '';
public password: string = '';
applyToRequest(requestOptions: RequestOptions): void {
requestOptions.auth = {
username: this.username, password: this.password
}
}
}*/
export class HttpBearerAuth implements Authentication {
public accessToken: string | (() => string) = '';
Expand Down
31 changes: 31 additions & 0 deletions doc/AddLanguage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# How to add a new language

In order to generate a client for a new language, here is a short guide:

## Extract the template

First you need to find your language in the list of generators:
[list](https://openapi-generator.tech/docs/generators)

Once you find your template you can extract it with the following command:
```bash
openapi-generator author template -g <your language generator> -o templates/<your language>
```

## Customize the template

There are a few components to add before generating the client, mostly:
- Init method
- Retry strategy
- maybe more

### Init method

By default, OpenAPI will put the `AppId` and `ApiKey` in every method, but we want an init method that takes those parameters and put them in the header of every requests, and create the right hosts.
To do this, change the constructor of the client in the `mustache` file to accept and store them.

### Retry strategy

The retry strategy cannot be included in the OpenAPI spec, you need to add a `<your language>` folder inside the `complement` folder and add your retry strategy code in that folder.

TODO finish this when we have more knowledge about the other languages.

0 comments on commit 30fba7a

Please sign in to comment.