所以我使用Swaggercodegen为我的Vue应用程序中的fetch客户机生成一个API客户机。
现在我想用公理代替,所以我用
OpenAPITools
类型脚本AXIOS代码生成器。
java -jar .\openapi-generator-cli.jar generate -i http://localhost:5000/swagger/v1/swagger.json -g typescript-axios -o app\api
当我试图将类型化响应赋给本地变量(同一类型)时:
@Component
export default class Themes extends Vue {
private themesApi!: ThemesApi;
private themes: Theme[];
constructor() {
super();
this.themes = [];
}
private async mounted() {
const apiConfig: Configuration = {
basePath: config.API_URL,
};
this.themesApi = new ThemesApi(apiConfig);
}
private async getThemes() {
this.themes = await this.themesApi.getThemes();
}
}
,我得到这个类型脚本错误:
> 139:5 Type 'AxiosResponse<Theme[]>' is missing the following
> properties from type 'Theme[]': length, pop, push, concat, and 28
> more.
> 137 |
> 138 | private async getThemes() {
> > 139 | this.themes = await this.themesApi.getThemes();
> | ^
局部变量的类型相同:
那么为什么我会得到这个错误呢?