【发布时间】:2018-01-14 22:43:57
【问题描述】:
我有一个用于 API 的 swagger 文件,该文件将驻留在 IBM API Connect 中。我是从 IBM 教程中打出来的,我试图复制讲师正在做的事情(他没有提供任何源文件,所以我不得不打出来)。
教程可在此处获得:https://www.youtube.com/watch?v=hCvUYd67rbI 这家伙在 21:40 左右将 swagger 文件复制粘贴到 APIConnect 本地设计器中。
我把 swagger 文件放到http://editor.swagger.io/ 中,我得到了一堆解析器错误:
Errors
Hide
Parser error duplicated mapping key
Jump to line 31
Semantic error at definitions.shipping.properties.xyz.type
Sibling values are not allowed alongside $refs
Jump to line 86
Semantic error at definitions.shipping.properties.cek.type
Sibling values are not allowed alongside $refs
Jump to line 89
我进行了一些挖掘,但没有找到很多资源来解决我的问题。我仔细检查了我是否从教程中正确输入了它。也许这与本教程中使用的旧版本的 API Connect 有关。
提前感谢任何可以提供帮助的人。
编辑:
不好意思,来晚了,累了,我在yaml文件中添加源代码:
info:
x-ibm-name: logistics
title: logistics
version: 1.0.0
schemes:
- https
basePath: /logistics
consumes:
- application/json
produces:
- application/json
securityDefinitions:
clientIdHeader:
type: apiKey
in: header
name: X-IBM-Client-Id
security:
- clientdHeader: []
x-ibm-configuration:
testable: true
enforced: true
cors:
enabled: true
gateway: datapower-gateway
catalogs:
apic-dev:
properties:
runtime-url: $(TARGET_URL)
properties:
shipping_svc_url:
value: 'http://shipping.think.ibm:5000/calculate'
description: Location of the shipping calculator service
encoded: false
paths:
/shipping:
get:
responses:
'200':
description: 200 OK
schema:
$ref: '#/definitions/shipping'
summary: Calculate shipping costs to a destination zip code
operationId: shipping.calc
parameters:
- name: zip
type: string
required: true
in: query
description: Destination zip code.
/stores:
get:
responses:
'200':
description: 200 OK
schema:
$ref: '#/definitions/store_location'
tags:
- stores
summary: Locate store near zip code
operationId: get.stores
parameters:
- name: zip
type: string
required: true
in: query
definitions:
rates:
properties:
next_day:
type: string
example: '20.00'
two_day:
type: string
example: '17.00'
ground:
type: string
example: '8.00'
required:
- two_day
- next_day
- ground
shipping:
properties:
xyz:
type: string
$ref: '#/definitions/rates'
cek:
type: string
$ref: '#/definitions/rates'
required:
- xyz
- cek
store_location:
properties:
google_maps_link:
type: string
example: 'https://www.google.com/maps?q=34.1030032,-118.4104684'
required:
- google_maps_link
【问题讨论】:
标签: parsing yaml swagger apiconnect