openapi2typescript
openapi2typescript copied to clipboard
一个被大范围使用的小工具
1.9.2 版本生成 functionName 后增加了 camelCase(functionName),如果自定义的 functionName 中包含下划线,camelCase 导致下划线丢失。 能否改成自定义的 functionName 不做 camelCase 处理。
https://github.com/chenshuai2144/openapi2typescript/pull/124/commits/5f45293973bb14d090a9d3d7a76ebb9ab8946585 比如: CommonController -> commonController SystemController -> systemController 是否应该提供配置出来是大驼峰还是小驼峰的格式? 毕竟SpringBoot的Controller是大驼峰的规范
目前发现 openapi 3.1 协议下,errorMessage字段类型定义会被解析成any 3.0 json片段 ```json "components": { "schemas": { "PageResponseResult": { "type": "object", "properties": { "success": { "type": "boolean", "description": "是否成功" }, "errorMessage": { "type": "string", "description": "错误信息",...
### 问题描述 空请求体的POST请求的schema在应用该插件时报错 ### 可能原因 此处的 `reqContent[mediaType]` 可能为 `undefined`。  ### 修复措施 加上这个`?`,解决了。
后端定义的返回结果中是 `Map` 这种类型的在 swagger json 中为 ```json { "type": "object", "additionalProperties": { "type": "array", "items": { "$ref": "#/components/schemas/AppVo" } } } ``` 对应的解析函数 `resolveObject` 中缺少对于此种情况的解析 最后产生的结果为: `Record` 期望产生的结果为: `Record` 涉及代码:...
https://github.com/chenshuai2144/openapi2typescript/blob/b035170d8c5a6bea14616a87e1d7ce7b1390440a/src/serviceGenerator.ts#L850-L852 这段代码中,由于 `resolveObject` 方法中对于对象的判断是必须有 `properties` 否则直接返回。 https://github.com/chenshuai2144/openapi2typescript/blob/b035170d8c5a6bea14616a87e1d7ce7b1390440a/src/serviceGenerator.ts#L724-L738 导致上面那段代码中的 [`getDefinesType`](https://github.com/chenshuai2144/openapi2typescript/blob/b035170d8c5a6bea14616a87e1d7ce7b1390440a/src/serviceGenerator.ts#LL728C15-L728C91) 返回的 type 值为 `true`,并且生成在 `typings.d.ts` 文件中
https://github.com/chenshuai2144/openapi2typescript/blame/b035170d8c5a6bea14616a87e1d7ce7b1390440a/src/serviceGenerator.ts#L178 在目前的178行,我们看到对required的处理是: ```javascript const required = 'required' in (schemaObject.properties[key] || {}) ? ((schemaObject.properties[key] || {}) as any).required : false; ``` 也就是说对于嵌入的对象是通过这个properties定义内部是否有一个required的bool字段来控制的,但是对于OpenAPI和JsonSchema规范来说,一个字段是否required应该是放在和properties同级的required的数组中。 ```openapi "schema": { "allOf": [ { "$ref": "#/components/schemas/Result" },...
如何带上登录信息Cookie?
```ts export const getSchema = async (schemaPath: string) => { if (schemaPath.startsWith('http')) { ... } const schema = require(schemaPath); return schema; }; ``` https://github.com/chenshuai2144/openapi2typescript/blob/b035170d8c5a6bea14616a87e1d7ce7b1390440a/src/index.ts#LL114C18-L114C25 如题,我在使用 `getSchema` 对本地文件的 json 进行加载时,由于存在轮询刷新该文件的逻辑,但是一直获取的都是第一次的内容。
例如这样的配置 ``` API中params使用引用 "parameters": [ { "$ref": "#/components/parameters/ProjectId" } ], 引用的parameters定义 "ProjectId": { "in": "path", "name": "projectId", "schema": { "$ref": "#/components/schemas/ProjectId" }, "required": true, "description": "project ID", "example": 1 },...