无法正常通过码云 swagger json 来生成 客户端
@Yashin 你好,想跟你请教个问题:
根据 码云提供的 swagger json 文件 https://gitee.com/api/v5/doc_json, 调用 2.4.0 的 swagger-codegen-cli https://github.com/swagger-api/swagger-codegen/tree/v2.4.0 来生成 golang的客户端时, 会抛出异常, 看起来是 API Schema 哪里有问题。
生成golang 客户端的命令如下
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i https://gitee.com/api/v5/doc_json -l go -o /tmp/java-gitee -DpackageName=gitee --model-package types --api-package=apis
生成 java 客户端的命令如下
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i https://gitee.com/api/v5/doc_json -l java -o /tmp/java-gitee -DpackageName=gitee --model-package types --api-package=apis
抛出异常如下:
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/java-gitee/docs/UserNotificationNamespace.md
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/java-gitee/src/main/java/types/UserNotificationSubject.java
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /tmp/java-gitee/docs/UserNotificationSubject.md
Exception in thread "main" java.lang.RuntimeException: Could not process operation:
Tag: Tag {
name: Labels
description: Operations about Labels
externalDocs: null
extensions:{}}
Operation: putV5ReposOwnerRepoIssuesNumberLabels
Resource: put /v5/repos/{owner}/{repo}/issues/{number}/labels
Definitions: {Branch=io.swagger.models.ModelImpl@12a7111a, CompleteBranch=io.swagger.models.ModelImpl@599e2938, RepoCommit=io.swagger.models.ModelImpl@e8019b35, Compare=io.swagger.models.ModelImpl@83bfc6a, SSHKey=io.swagger.models.ModelImpl@bcf608a6, SSHKeyBasic=io.swagger.models.ModelImpl@50007ac9, Content=io.swagger.models.ModelImpl@6172dcf9, CommitContent=io.swagger.models.ModelImpl@c8a85bb1, ContentBasic=io.swagger.models.ModelImpl@bf3a6d00, Commit=io.swagger.models.ModelImpl@1fbfc113, Blob=io.swagger.models.ModelImpl@1665c562, Tree=io.swagger.models.ModelImpl@afa57d6d, Issue=io.swagger.models.ModelImpl@15c20c6d, Label=io.swagger.models.ModelImpl@a90ddb52, UserBasic=io.swagger.models.ModelImpl@412bea14, Milestone=io.swagger.models.ModelImpl@6f0b3291, OperateLog=io.swagger.models.ModelImpl@a8bc5e3b, Note=io.swagger.models.ModelImpl@600d17e9, Project=io.swagger.models.ModelImpl@e9619d75, Contributor=io.swagger.models.ModelImpl@ad66b10, Tag=io.swagger.models.ModelImpl@12f21e51, ProjectMember=io.swagger.models.ModelImpl@f23386b9, ProjectMemberPermission=io.swagger.models.ModelImpl@fc6d91fa, PullRequest=io.swagger.models.ModelImpl@811e1084, PullRequestComments=io.swagger.models.ModelImpl@ad4e82aa, PullRequestCommits=io.swagger.models.ModelImpl@40dc17df, PullRequestFiles=io.swagger.models.ModelImpl@a89fe64c, Release=io.swagger.models.ModelImpl@dcff5364, Hook=io.swagger.models.ModelImpl@ad765b91, Event=io.swagger.models.ModelImpl@79276ba7, UserNotificationList=io.swagger.models.ModelImpl@5c5a1c9, UserNotification=io.swagger.models.ModelImpl@4ce5ffaf, ProjectBasic=io.swagger.models.ModelImpl@5ff7f399, UserNotificationSubject=io.swagger.models.ModelImpl@e7338a6a, UserNotificationNamespace=io.swagger.models.ModelImpl@676fd933, Group=io.swagger.models.ModelImpl@37481ba0, UserDetail=io.swagger.models.ModelImpl@88089f32, UserAddress=io.swagger.models.ModelImpl@8d43ce57, UserEmail=io.swagger.models.ModelImpl@dfe94d55, Namespace=io.swagger.models.ModelImpl@f54ca9e5, NamespaceMini=io.swagger.models.ModelImpl@2442e994, GroupMember=io.swagger.models.ModelImpl@28a7bbca, Code=io.swagger.models.ModelImpl@ba4a0d87, CodeForksHistory=io.swagger.models.ModelImpl@dbf70184, CodeComment=io.swagger.models.ModelImpl@3a2c5461, CodeForks=io.swagger.models.ModelImpl@fa305df2, User=io.swagger.models.ModelImpl@fea08958, GroupDetail=io.swagger.models.ModelImpl@2350b8b4, UserNotificationCount=io.swagger.models.ModelImpl@ae1418f1, UserMessageList=io.swagger.models.ModelImpl@159bcce3, UserMessage=io.swagger.models.ModelImpl@a08409a5}
Exception: null
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:940)
at io.swagger.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:818)
at io.swagger.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:439)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:754)
at io.swagger.codegen.cmd.Generate.run(Generate.java:285)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
Caused by: java.lang.NullPointerException
at io.swagger.codegen.DefaultCodegen.getExamples(DefaultCodegen.java:3828)
at io.swagger.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:2275)
at io.swagger.codegen.languages.AbstractJavaCodegen.fromOperation(AbstractJavaCodegen.java:1094)
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:889)
... 5 more
能帮忙看下是怎么回事么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个不太清楚哎,码云的api web 测试页面是做个适应的,我也不太清楚 swagger 新的标准是不是有做过调整