kotlin - 如何运行 Swagger Codegen 生成的 Kotlin 服务器?
问题描述
我无法运行kotlin-server
Swagger Codegen v. 3 生成的文件。
该.yaml
文件是:
openapi: 3.0.0
info:
title: Experiement with Swagger
description: Test
version: 1.0.0
servers:
- url: 'http://localhost:8080'
description: production server's url
tags:
- name: Test
description: Test
externalDocs:
description: Find out more
url: 'http://localhost:8080'
paths:
/testURI:
post:
tags:
- Test
summary: Test
description: Test
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Test'
responses:
'200':
description: Test success
content:
application/json:
schema:
$ref: '#/components/schemas/TestSuccessResponse'
'404':
description: >-
Only a signed in user can add a question. This response means that
the user isn't signed in.
content:
application/json:
schema:
$ref: '#/components/schemas/UnauthorisedErrorResponse'
'500':
description: >-
means some internal error occur on the server while doing the
operation. The state of the operation if un-determined and the
operation could be succesful, failed or partially successful
(because some database operations are not rolled back if error
occurs!
content:
application/json:
schema:
$ref: '#/components/schemas/InternalServerErrorResponse'
components:
schemas:
Test:
type: object
properties:
some-input:
type: string
TestSuccessResponse:
type: object
properties:
result:
type: string
enum:
- success
additional-info:
type: string
enum:
- Test successful
required:
- result
- additional-info
UnauthorisedErrorResponse:
type: object
properties:
result:
type: string
enum:
- error
additional-info:
type: string
enum:
- Not authorised
required:
- result
- additional-info
InternalServerErrorResponse:
type: object
properties:
result:
type: string
enum:
- error
additional-info:
type: string
enum:
- Internal Server Error
required:
- result
- additional-info
我将它粘贴到 Swagger 编辑器中,下载kotlin-server
kotlin-server-server-generated.zip
,解压缩C:\Users\manu\Documents\manu\kotlin-server-server-generated
,打开Readme.MD
文件并按照其中的说明进行操作。
在使用 Windowscmd
时C:\Users\manu\Documents\manu\kotlin-server-server-generated
,
我首先运行了gradle wrapper
.
我得到了这个输出:
启动一个 Gradle 守护程序,1 个不兼容的和 2 个停止的守护程序无法重用,使用 --status 了解详细信息
构建缓存是一个孵化功能。在 17 秒内构建成功
1 个可操作的任务:1 个已执行
然后我跑了gradlew check assemble
:
C:\Users\manu\Documents\manu\kotlin-server-server-generated>gradlew check assemble
启动一个 Gradle 守护进程,1 个不兼容和 2 个停止的守护进程无法重用,详细信息使用 --status
构建缓存是一个孵化功能.
w: C:\Users\manu\Documents\manu\kotlin-server-server-generated\src\main\kotlin\io\swagger\server\apis\TestApi.kt: (51, 9): 变量 'gson' 是从未使用
w: C:\Users\manu\Documents\manu\kotlin-server-server-generated\src\main\kotlin\io\swagger\server\apis\TestApi.kt: (52, 9): 变量 'empty ' 从未使用过任务 :startShadowScripts
将 TaskInputs.file() 与无法解析为 File 对象的内容一起使用已被弃用,并计划在 Gradle 5.0 中删除。请改用 TaskInputs.files()。在 36 秒内构建成功
10 个可操作的任务:10 个已执行
然后我跑了java -jar ./build/libs/kotlin-server.jar
。
但是当我将浏览器指向 时localhost:8080
,我看到了Page Not Found
。
我究竟做错了什么?
解决方案
推荐阅读
- python - 我正在处理simpleimputer并在python中出现错误“输入包含NaN,无穷大或对于dtype('float64')来说太大的值”这是我的代码
- swift - SwiftUI / Combine:监听数组项值变化
- javascript - 用元素之间的动画对拖放和连接箭头(或其他任何东西)做出反应
- sql - 在表上做左连接
- bash - 如何在 BASH 中同时创建带时间戳的日志和错误句柄?
- android - 以编程方式生成的动态链接不起作用?
- javascript - 如何将音频文件字节频率数据导出到 JSON 对象?
- python - Ubuntu 18.04 Python3 Selenium webdriver安装问题
- wpf - 如何将按钮保留在数据网格标题的右侧
- laravel - laravel 传递给控制器时得到未定义的变量?