<small id='vm8mb'></small><noframes id='vm8mb'>

      <i id='vm8mb'><tr id='vm8mb'><dt id='vm8mb'><q id='vm8mb'><span id='vm8mb'><b id='vm8mb'><form id='vm8mb'><ins id='vm8mb'></ins><ul id='vm8mb'></ul><sub id='vm8mb'></sub></form><legend id='vm8mb'></legend><bdo id='vm8mb'><pre id='vm8mb'><center id='vm8mb'></center></pre></bdo></b><th id='vm8mb'></th></span></q></dt></tr></i><div id='vm8mb'><tfoot id='vm8mb'></tfoot><dl id='vm8mb'><fieldset id='vm8mb'></fieldset></dl></div>

    1. <legend id='vm8mb'><style id='vm8mb'><dir id='vm8mb'><q id='vm8mb'></q></dir></style></legend><tfoot id='vm8mb'></tfoot>
        <bdo id='vm8mb'></bdo><ul id='vm8mb'></ul>

    2. 从 Yaml 文件为 Request 和 Response 对象生成 Java 类

      时间:2023-09-26

    3. <legend id='JxO84'><style id='JxO84'><dir id='JxO84'><q id='JxO84'></q></dir></style></legend>
        <tbody id='JxO84'></tbody>

      <i id='JxO84'><tr id='JxO84'><dt id='JxO84'><q id='JxO84'><span id='JxO84'><b id='JxO84'><form id='JxO84'><ins id='JxO84'></ins><ul id='JxO84'></ul><sub id='JxO84'></sub></form><legend id='JxO84'></legend><bdo id='JxO84'><pre id='JxO84'><center id='JxO84'></center></pre></bdo></b><th id='JxO84'></th></span></q></dt></tr></i><div id='JxO84'><tfoot id='JxO84'></tfoot><dl id='JxO84'><fieldset id='JxO84'></fieldset></dl></div>

        <small id='JxO84'></small><noframes id='JxO84'>

            <bdo id='JxO84'></bdo><ul id='JxO84'></ul>
            <tfoot id='JxO84'></tfoot>

                本文介绍了从 Yaml 文件为 Request 和 Response 对象生成 Java 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我们使用 Swagger 编辑器为我们的 API 规范创建了一个 Yaml 文件,其中包括基本 URL、端点、请求、响应和标头信息等.现在我想为这些 API 实现 RESTful Web 服务.为此,我正在考虑从这个 Yaml 文件生成我的请求和响应 Java 类,并且正在寻找某种代码生成器,最好是我可以在我的 Maven 项目中使用的 Maven 插件/依赖项.我遇到了这个 rest client with swagger 谈到使用 swagger-codegen Maven 插件,但这是为了生成 client 我相信它是关于生成客户端代码以使用这些 RESTful API,但是我需要生成类来用于服务实现.我将使用 Java 和 Spring 框架.

                We have created a Yaml file using Swagger editor for our APIs specification which includes Base URL, endpoint, Request, Response and Header information etc.. Now I want to implement RESTful web service for these APIs. For that I am thinking of generating my Request and Response Java classes from this Yaml file and was looking for some kind of code generator, preferably a maven plugin/dependency which I could use in my Maven project. I came across this rest client with swagger which talks about using the swagger-codegen Maven plugin, but this is to generate the client which I believe is about generating the client code to consume these RESTful APIs, however my need is to generate classes to be used for service implementation. I will be using Java and Spring framework.

                我的问题是,当我们拥有 Yaml 文件(使用 Swagger 编辑器创建的 API 规范)以及可以使用哪些代码生成工具/插件时,在 Java 中实现 RESTful Web 服务的最佳实践是什么.

                My question is what are the best practices for implementing the RESTful web services in Java when we have Yaml file (API spec created using Swagger editor) and which code generation tools/plugins are available to be used.

                刚刚遇到这个 服务器存根生成器 HOWTO,进一步研究.

                Just came across this Server stub generator HOWTO, looking further into it.

                推荐答案

                Swagger-codegen maven 插件是一个不错的选择,但我建议你使用 jhipster 来生成你的java项目.它生成具有最新技术堆栈的项目,包括 spring 框架.您可以根据自己的情况选择 API-First development.我用过,效率很高.你已经有了 Yaml 文件.放入 src/main/resources/swagger/api.yml 并运行

                Swagger-codegen maven plugin is a good option but I suggest you to use jhipster to generate your java project. It generates projects with latest tech stack including spring framework. You can select API-First development in your case. I used it and it was very efficient. You already have Yaml file. Put it in src/main/resources/swagger/api.yml and run

                    ./mvnw generate-sources
                

                将生成所有 java 代码.

                All java codes will be generated.

                这篇关于从 Yaml 文件为 Request 和 Response 对象生成 Java 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:用于 java 的 Travis CI yml 文件示例 下一篇:使用snakeYaml解析根有地图的YAML文档

                相关文章

                最新文章

                  <bdo id='pKfqi'></bdo><ul id='pKfqi'></ul>
              • <i id='pKfqi'><tr id='pKfqi'><dt id='pKfqi'><q id='pKfqi'><span id='pKfqi'><b id='pKfqi'><form id='pKfqi'><ins id='pKfqi'></ins><ul id='pKfqi'></ul><sub id='pKfqi'></sub></form><legend id='pKfqi'></legend><bdo id='pKfqi'><pre id='pKfqi'><center id='pKfqi'></center></pre></bdo></b><th id='pKfqi'></th></span></q></dt></tr></i><div id='pKfqi'><tfoot id='pKfqi'></tfoot><dl id='pKfqi'><fieldset id='pKfqi'></fieldset></dl></div>

                <small id='pKfqi'></small><noframes id='pKfqi'>

              • <tfoot id='pKfqi'></tfoot>
                1. <legend id='pKfqi'><style id='pKfqi'><dir id='pKfqi'><q id='pKfqi'></q></dir></style></legend>