【发布时间】:2015-04-29 15:31:48
【问题描述】:
我最近开始使用 swagger 为我们的 RESTful api 生成文档。我使用 yamlbeans-1.09.jar 将我的 Java DTO 转换为 yaml 文件。 一切正常,并且 yaml 甚至在 http://www.yamllint.com/ 上得到了正确验证,但仍然在使用 Swagger 接口对其进行测试时,它给出了一个错误 "Expected type string but found type integer" 和 "No enum match for: 2" 我在文件中提到 swagger : 2.0 的地方。
我的示例 yml 文件是:
basePath: /employment
host: api.xxxx.com
schemes:
- https
swagger: 2.0
info:
title: API Doc
description: Description for the info goes here
version: 1.0.0
它总是倾向于在 swagger 版本之前只给出一个行号。任何帮助将不胜感激。
编辑:我已经在java代码中将swagger版本定义为字符串,写法如下:
HashMap<String, Object> rootElementsForYml = new HashMap<String, Object>();
rootElementsForYml.put(SWAGGER, "2.0");
rootElementsForYml.put(HOST, "api.xxxx.com");
rootElementsForYml.put(BASEPATH, basePath);
rootElementsForYml.put(SCHEMES, new String[]{"https"});
但它仍然没有给出结果和同样的错误。
【问题讨论】: