Closed fulvio-diller closed 4 months ago
Hi thanks, I agree, there isn't a lot of documentation yet. The TSDoc should give some information but it's not ideal.
I'm not sure on what you mean by variableConfiguration
?
When we create a new context, like so:
const ctx = createContext({
serverConfiguration: new ServerConfiguration(
process.env.BASE_URL || "",
{} //variableConfiguration
),
});
I see
The variableConfiguration
object is here to map to the OpenAPI spec in the server
object. Most of the time you don't really need to specify it (you can leave an empty {}
).
A simple example could be (using the OpenAPI spec example):
new ServerConfiguration(
'https://{username}.gigantic-server.com:{port}/{basePath}"',
{ username: 'demo', port: '443', basePath: '/v2' },
);
Typoas will automatically set the variables in the base URL
PS: The ServerConfiguration
system is not as good as I'd want, I should see to improve this
Thanks for the info, if we have ann Api Token how do we setup?
Thanks for the info, if we have ann Api Token how do we setup?
This will not be related to ServerConfiguration but more on the authProviders
object:
createContext({
authProviders: {
'my-auth-mode': {
async getConfig() {
return { token: 'My token' };
},
},
},
});
Where my-auth-mode
is the name of the securityScheme
declared on the OpenAPI, each auth provider must provide a getConfig
method that return a token or other (depending on the auth mode).
If the authProviders doesn't match your need, you can also just override the default fetcher
and handle the authentication on the Fetcher
level
Thanks for the help, you can close this issue :smile:
I'll keep this open for now, so people can find a small example and so I don't forget that it needs a better documentation with more examples and explaination
I added some example on the configuration of createContext
to be a little bit more easy to customize
Hi there great tool, but the documentation and examples for variableConfiguration are a bit limited:
Can you add Documentation about Auth, Headers etc?
Thanks.