Swagger Codegen IO:更改服务命名约定和昵称

编程入门 行业动态 更新时间:2024-10-28 12:22:01
本文介绍了Swagger Codegen IO:更改服务命名约定和昵称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在创建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:更改服务命名约定和昵称

本文发布于:2023-11-15 09:20:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1593155.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:昵称   Swagger   Codegen   IO

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!