我有一个非常简单的OpenAPI / Swagger配置(openapi.yaml):
swagger: '2.0'
info:
title: My Service
version: 1.0
description: A description for My Service
basePath: /my-service
schemes:
- https
produces:
- application/json
我已经配置了Maven Swagger Codegen插件。运行时,
> mvn clean install
我收到以下错误:
java.lang.NullPointerException
at io.swagger.codegen.DefaultGenerator.processPaths (DefaultGenerator.java:806)
at io.swagger.codegen.DefaultGenerator.generateApis (DefaultGenerator.java:431)
at io.swagger.codegen.DefaultGenerator.generate (DefaultGenerator.java:746)
...
答案 0 :(得分:2)
问题是paths
字段是必填字段。即使您不希望包含任何路径,也必须使用空对象指定该路径:
paths: {}
将openapi.yaml更新为以下内容将摆脱所描述的NPE:
swagger: '2.0'
info:
title: My Service
version: 1.0
description: A description for My Service
basePath: /my-service
schemes:
- https
produces:
- application/json
paths: {}