gpt4 book ai didi

rest - Swagger codegen - api 和模型

转载 作者:行者123 更新时间:2023-12-05 05:57:55 29 4
gpt4 key购买 nike

所以这对我来说是 codegen101,我一直在尝试使用 swagger 插件并不断收到错误。这是一个已知问题吗,我已经尝试过该插件的多个版本,认为其中一个可能是一个已知问题,但根本没有成功。这应该是非常简单的练习。我不确定我错过了什么。有人可以指出吗

 <build>
<plugins>
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.18</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/service-api.yaml</inputSpec>
<language>java</language>
<output>${project.build.directory}/generated-sources/</output>
<generateSupportingFiles>false</generateSupportingFiles>
<apiPackage>com.openapi101.api</apiPackage>
<modelPackage>com.openapi101.models</modelPackage>
<configOptions>
<interfaceOnly>true</interfaceOnly>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>

错误

[ERROR]
java.lang.RuntimeException: Could not generate model 'Book'
at io.swagger.codegen.v3.DefaultGenerator.generateModels (DefaultGenerator.java:451)
at io.swagger.codegen.v3.DefaultGenerator.generate (DefaultGenerator.java:779)
at io.swagger.codegen.v3.maven.plugin.CodeGenMojo.execute (CodeGenMojo.java:547)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:567)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: com.github.jknack.handlebars.HandlebarsException: /handlebars/JavaSpring/pojo.mustache:2:6: java.lang.reflect.InaccessibleObjectException: Unable to make public boolean java.util.Collections$EmptyMap.isEmpty() accessible: module java.base does not "opens java.util" to unnamed module @4bc33720
/handlebars/JavaSpring/pojo.mustache:2:6
at java.lang.reflect.AccessibleObject.checkCanSetAccessible (AccessibleObject.java:357)

编辑:使用新版本 - 3.0.27。还是不行

这是yaml文件

openapi: 3.0.0

info:
version: 0.0.1
title: Library Service
description: The library service

tags:
- name: "Library"


paths:

/library/books:
get:
summary: This is summary
tags:
- "Library"
description: This is a description
operationId: getAllBooksInLibrary
responses:
"200":
description: This means its ok
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Book'

components:

schemas:

Book:
description: This is the book model
type: object
properties:
name:
description: The name of book
type: string
bookAuthor:
description: name of author
type: string

最佳答案

我遇到了同样的问题。解决方案是简单地使用 Java 8 来运行它。这让我可以毫无问题地运行这一代

关于rest - Swagger codegen - api 和模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68661167/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com