在创建Angular API服务代理时,是否仍然要覆盖Swagger IO CodeGen命名约定?
Is there anyway to override Swagger IO CodeGen naming conventions, when its creating Angular API Service Proxies?
editor.swagger.io/
按以下等式命名:API +控制器名称+控制器方法+ HTTP操作.
Its naming by this equation: API + Controller Name + Controller Method + HTTP Action.
public apiProductGetProductByProductIdGet(productNumber?: string, observe?: 'body', reportProgress?: boolean): Observable<ProductResponse>;我们要为公司重新命名/命名惯例.
We want to restructure/reorder the naming convention for our company.
当前将Net Core 3 API与Angular Typescript链接.
Currently linking Net Core 3 APIs with Angular Typescript.
将接受CodeGen的javascript答案.
Will accept javascript answer for CodeGen.
更新可能的解决方案:
如何在C#中更改昵称属性?
How do I change the nickname property in C#?
docs.swagger.io/spec.html
"昵称.该操作的唯一ID,工具可以使用该ID读取输出,以进一步简化操作.例如,Swagger-Codegen将使用昵称作为其生成的客户端中操作的方法名称.该值必须为字母数字,并且可以包含下划线.不允许使用空格字符.
"Nickname. A unique id for the operation that can be used by tools reading the output for further and easier manipulation. For example, Swagger-Codegen will use the nickname as the method name of the operation in the client it generates. The value MUST be alphanumeric and may include underscores. Whitespace characters are not allowed.
"nickname": "addPet", 推荐答案您正在寻找 operationId 属性:
operationId 是可选的唯一字符串,用于标识手术.如果提供,这些ID在所有操作中必须是唯一的在您的API中进行了说明.
operationId is an optional unique string used to identify an operation. If provided, these IDs must be unique among all operations described in your API.
swagger.io/docs/specification/paths-and-操作/
示例:
/users: get: operationId: getUsers summary: Gets all users ... post: operationId: addUser summary: Adds a new user ... /user/{id}: get: operationId: getUserById summary: Gets a user by user ID ...如果您使用的是 Swashbuckle ,您可以通过以下两种不同方式指定operationId:
If you're using Swashbuckle, you can specify the operationId a couple of different ways below:
[HttpGet("{id:int}", Name = nameof(GetProductById))] public IActionResult GetProductById(int id) // operationId = "GetProductById"'或
[HttpGet("{id:int}", Name = "GetProductById")] public IActionResult GetProductById(int id) // operationId = "GetProductById"'另请参见此
更多推荐
Swagger Codegen IO:更改服务命名约定和昵称
发布评论