我目前正在使用 Swagger php 库:https://github.com/DarkaOnLine/L5-Swagger
在我的示例模型类中是这样的:
/** @OA\Schema(
* title="ProductPromotion",
* @OA\Property(property="id", type="integer"),
* @OA\Property(property="uid", type="string"),
* @OA\Property(property="store_id", type="integer"),
* )
*/
class ProductPromotion extends Model
{
..
}
请注意,我在第三个属性中写了“store_id”。但是当我使用这个jar文件时: openapi-generator-cli-4.1.3,我得到的界面是这样的:
export interface ProductPromotion {
id?: number;
uid?: string;
storeId?: number;
}
名称从“store_id”更改为“storeId”。我不想要这个,有人知道如何解决这个问题吗?
编辑:用于生成的命令:
java -jar openapi-generator-cli-4.1.3.jar generate -i C:\Users\ASUS\Desktop\OpenAPICodegen\swagger.json -g typescript-angular -o C:\Users\ASUS\Desktop\OpenAPICodegen\dist
最佳答案
也许这可以帮助你:
https://github.com/openapitools/openapi-generator/wiki/FAQ
TypeScript The JSON response failed to deserialize properly into the object due to change in variable naming (snake_case to camelCase). Is there any way to keep the original naming? Yes, please use the following option when generating TypeScript clients:
modelPropertyNaming
Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name (Default: camelCase)
关于php - DarkaOnline Swagger-php 生成错误的界面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59375173/