简体   繁体   English

如何将 openapi.yaml 添加到您的项目中

[英]How to add openapi.yaml to your project

How to add openapi.yaml to an existing project with already written code for REST API?如何将 openapi.yaml 添加到已经为 REST API 编写代码的现有项目中? In what folder should I put the yaml file and what "configuration" needs to be done for it to work properly (display swagger UI)?我应该将 yaml 文件放在哪个文件夹中,需要进行哪些“配置”才能使其正常工作(显示 swagger UI)?

Note: using dropwizard framework注意:使用dropwizard框架

I was running into several issues myself using Open API with Spring/Dropwizard.我自己在使用 Open API 和 Spring/Dropwizard 时遇到了几个问题。 So I started building an alternative that makes repo integration easier ( https://github.com/fern-api/fern ).所以我开始构建一个替代方案,使 repo 集成更容易 ( https://github.com/fern-api/fern )。

Steps to get started:开始步骤:

  1. You can install it with npm install -g fern-api您可以使用npm install -g fern-api安装它
  2. Run fern init which will create an api directory that has an API definition运行fern init将创建一个 api 目录,该目录具有 API 定义
  3. Run fern add java to add the java generator运行fern add java添加 java 生成器
  4. Run fern generate to generate the java subproject运行fern generate生成 java 子项目
  5. Add a dependency on the java subproject and implement your APIs添加对 java 子项目的依赖并实现您的 API

https://docs.buildwithfern.com/#/ There's a video here on how to get started with Java. https://docs.buildwithfern.com/#/这里有一个关于如何开始使用 Java 的视频。

If you want to add an openapi.yml after, you will be able to convert the fern api definition into a valid Open API.如果你想在之后添加openapi.yml ,你将能够将 fern api 定义转换为有效的 Open API。

Apologies if this wasn't the answer you were looking for, just figured I'd share an alternative that might solve your problem!如果这不是您正在寻找的答案,我们深表歉意,只是想我会分享一个可能解决您问题的替代方案!

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

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