-
-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api calls names #380
Comments
@VitaliKhileuski in case you are still wondering you can specify the name in swagger via the "operationId" property and the generator will use that name instead |
Hello @VitaliKhileuski ! Where
|
Otherwise you are able to change operation id with using templates Also FYI - return value from |
@js2me Thanks, I used operation id as names |
Where should I put the config with hooks? In what file and what folder? I just have swagger.json in my root folder of react app and then just run npx swagger-typescript-api ...etc |
@Leningram Hi! You can put config with hooks where you want! I put config at the root of project, near with src, types folder inside the And use this scripts from package.json And thats my config require('dotenv').config();
const { generateApi } = require("swagger-typescript-api");
const path = require('path');
const generateOperationId = require("./generateOperationId");
generateApi({
url: process.env.SWAGGER_SCHEMA,
output: path.resolve(__dirname, '../src/shared/api/__generated__'),
templates: path.resolve(__dirname, './templates'),
httpClientType: "axios",
cleanOutput: true,
modular: true,
singleHttpClient: true,
moduleNameIndex: 2,
extractRequestBody: true,
extractRequestParams: true,
extractResponseBody: true,
extractResponseError: true,
generateResponses: true,
sortTypes: true,
hooks: {
onFormatRouteName: (routeInfo, templateRouteName) => {
if (!routeInfo.operationId) {
return generateOperationId(routeInfo);
}
return templateRouteName;
},
onPrepareConfig: (configuration) => {
// configuration.routes.combined = configuration.routes.combined.filter(route => route.moduleName !== "ws")
}
}
}) |
How can i customize name generating of api calls? For this moment i see that name generate from route parts and word Create that is not comfortable for me
The text was updated successfully, but these errors were encountered: