Added additional documentation for configuration object

This commit is contained in:
Tino Fuhrmann 2021-08-29 21:52:57 +02:00
parent 0b8c08c7a0
commit 358baae19c
2 changed files with 26 additions and 8 deletions

View File

@ -24,29 +24,45 @@ export interface Configuration {
*/
export interface ConfigurationParameters {
/**
* Default server to use
* Default server to use - a list of available servers (according to the
* spec) is included in the `servers` const in `./servers`. You can also
* create your own server with the `ServerConfiguration` class from the same
* file.
*/
baseServer?: BaseServerConfiguration;
/**
* HTTP library to use e.g. IsomorphicFetch
* HTTP library to use e.g. IsomorphicFetch. This can usually be skipped as
* all generators come with a default library.
* If available, additional libraries can be imported from `./http/*`
*/
httpApi?: HttpLibrary;
/**
* The middlewares which will be applied to requests and responses
* The middlewares which will be applied to requests and responses. You can
* add any number of middleware components to modify requests before they
* are sent or before they are deserialized by implementing the `Middleware`
* interface defined in `./middleware`
*/
middleware?: Middleware[];
/**
* Configures all middlewares using the promise api instead of observables (which Middleware uses)
* Configures middleware functions that return promises instead of
* Observables (which are used by `middleware`). Otherwise allows for the
* same functionality as `middleware`, i.e., modifying requests before they
* are sent and before they are deserialized.
*/
promiseMiddleware?: PromiseMiddleware[];
/**
* Configuration for the available authentication methods
* Configuration for the available authentication methods (e.g., api keys)
* according to the spec. For the definition, please refer to
* `./auth/auth`
*/
authMethods?: AuthMethodsConfiguration
}
/**
* Configuration factory function
* Provide your `ConfigurationParameters` to this function to get a `Configuration`
* object that can be used to configure your APIs (in the constructor or
* for each request individually).
*
* If a property is not included in conf, a default is used:
* - baseServer: server1

View File

@ -14,9 +14,11 @@ export class ServerConfiguration<T extends { [key: string]: string }> implements
public constructor(private url: string, private variableConfiguration: T) {}
/**
* Sets the value of the variables of this server.
* Sets the value of the variables of this server. Variables are included in
* the `url` of this ServerConfiguration in the form `{key}`
*
* @param variableConfiguration a partial variable configuration for the variables contained in the url
* @param variableConfiguration a partial variable configuration for the
* variables contained in the url
*/
public setVariables(variableConfiguration: Partial<T>) {
Object.assign(this.variableConfiguration, variableConfiguration);