简体   繁体   English

JHipster - REST API 的最佳实践

[英]JHipster - Best practices for REST API

I'm trying to create a REST API using JHipster.我正在尝试使用 JHipster 创建一个 REST API。

  1. Is JHipster available for creating REST Api? JHipster 是否可用于创建 REST Api?
  2. Should I create the paths and DTOs using Openapi (swagger) or with JHipster?我应该使用 Openapi (swagger) 还是使用 JHipster 创建路径和 DTO?
  3. Is there an easier way to create REST Api with Spring Boot other than JHipster?有没有比 JHipster 更简单的方法来使用 Spring Boot 创建 REST Api? (Includes advanced features such as Test, CI/CD, Cloud, Hibernate, Cache) (包括高级功能,如测试、CI/CD、云、Hibernate、缓存)

What I've tried so far:到目前为止我已经尝试过:

I have created DTO and RequestMappings using Swagger but I have to struggle to map them to Entity.我已经使用 Swagger 创建了 DTO 和 RequestMappings,但我不得不努力将它们映射到实体。 On the other hand, if I try to build using JHipster, it creates them all automatically, but I can't take advantage of Openapi.另一方面,如果我尝试使用 JHipster 进行构建,它会自动创建它们,但我无法利用 Openapi。 Which one do you recommend?你推荐哪一个?

Of course, JHipster can create REST APIs, that's one of its main features and it can do it using 2 approaches: code-first and API-first.当然,JHipster 可以创建 REST API,这是它的主要特性之一,它可以使用两种方法来实现:代码优先和 API 优先。

Code-first is the default approach in JHipster and it generates the openapi/swagger specification and documentation from annotations.代码优先是 JHipster 中的默认方法,它从注释生成 openapi/swagger 规范和文档。

API-first is the reverse, you build manually an openapi/swagger specification and generate code from it. API 优先是相反的,您手动构建 openapi/swagger 规范并从中生成代码。 However, the generated code is not complete and requires manual coding.但是生成的代码并不完整,需要手工编码。 See https://www.jhipster.tech/doing-api-first-development/请参阅https://www.jhipster.tech/doing-api-first-development/

Code first is where JHipster will help you more. Code first 是 JHipster 可以帮助你的地方。 Both approaches can be mixed in a JHipster application.这两种方法都可以在 JHipster 应用程序中混合使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM