英文:
Using openapi-generator for typescript-angular, how to generate just a module inside an existing Angular project instead a full separate package?
问题
我正在使用 openapi-generator 生成 typescript-angular 模块。
我可以成功生成一个包含所有构件的Angular模块,但它是一个单独的npm包。
我明白这种方法有其好处,一个单独的包可以以专业的方式进行维护、版本化、分发等。
然而,我仍然想要在我的现有Angular应用程序中生成一个新模块。是否有一种配置生成器以完成这项任务的方式?
如果不能,那么需要哪些手动步骤来转换和集成生成的源代码以获得这个结果(即在我的现有Angular应用程序中创建一个模块)?
英文:
I am using openapi-generator for typescript-angular.
I can successfully generate an Angular module, with all artifacts, however it is a separate npm package.
I do understand, that this approach has its benefits, and a separate package can be maintained, versioned, distributed etc, in a professional way.
However still, I would like to just generate a new module inside in my existing Angular application. Is there a way to configure the generator to accomplish that task?
In case if not, what manual steps are required to transform and integrate the generated source code to get this result (meaining: a module in my existing Angular application)
答案1
得分: 3
如果您使用以下命令:
openapi-generator-cli generate -i yourApiYAMLfile.yaml -g typescript-angular -o src/app/api
或者
openapi-generator-cli generate -i yourApiSwaggerfile.json -g typescript-angular -o src/app/api
来生成您的客户端代码,作为您的应用程序的一部分。
然后,您可以直接从您的应用程序中使用生成的模型和服务。
查看我根据此创建的文章:https://blog.josematos.work/use-auto-generated-client-code-to-consume-your-api-from-an-angular-app-363c64f6c83a
英文:
If you use this command:
openapi-generator-cli generate -i yourApiYAMLfile.yaml -g typescript-angular -o src/app/api
or
openapi-generator-cli generate -i yourApiSwaggerfile.json -g typescript-angular -o src/app/api
to generate your client code as part of your app.
You can then use the models and services generated, directly from your app.
Check this article I wrote out of this: https://blog.josematos.work/use-auto-generated-client-code-to-consume-your-api-from-an-angular-app-363c64f6c83a
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论