我正在使用IBM的APIConnect創建一些API。我一直試圖編輯我的API的YAML定義來創建對屬性的引用,以便我可以將它們外部化。但到目前爲止,我一直在遇到與參考有關的問題。它們要麼不針對「API Connect swagger擴展模式API定義」進行驗證,要麼針對「IBM Swagger 2.0版模式API定義」進行驗證。
這裏有兩個引用我想: -
- 引用securityDefinitions: 在IBM網站描述:https://www.ibm.com/support/knowledgecenter/en/SSMNED_5.0.0/com.ibm.apic.toolkit.doc/rapic_swagger_ref_fragment.html
我YAML: -
swagger: '2.0'
info:
version: 1.0.0
title: PokemonApp
x-ibm-name: pokemonapp
host: $(catalog.host)
basePath: /api
paths:
/pokemon:
get:
responses:
'200':
description: 200 OK
securityDefinitions:
$ref: ./schemas/ClientID.yaml
security:
- clientID: []
x-ibm-configuration:
assembly:
execute:
- invoke:
target-url: $(TestProperty)
properties:
TestProperty:
value: 'https://pokemons.mybluemix.net/api/pokemons'
description: ''
encoded: false
gateway: micro-gateway
而且它的相應的參考文件: -
clientID:
description: ''
in: query
name: client_id
type: apiKey
在父YAML,我得到以下錯誤做一個APIC驗證: -
C:\Users\MyName\TestNotes\definitions>apic validate pokemonapp_1.0.0.yaml
Successfully validated pokemonapp_1.0.0.yaml against Swagger Version 2.0 schema API definition [pokemonapp:1.0.0].
Successfully validated pokemonapp_1.0.0.yaml against API Connect swagger extensions schema API definition [pokemonapp:1.0.0].
Error validating pokemonapp_1.0.0.yaml with IBM Swagger Version 2.0 schema API definition [pokemonapp:1.0.0].
Data does not match any schemas from "oneOf" (/securityDefinitions/$ref)
Error: Validation did not complete successfully.
- 引用屬性: -
這裏的父YAML: -
swagger: '2.0'
info:
version: 1.0.0
title: PokemonApp
x-ibm-name: pokemonapp
host: $(catalog.host)
basePath: /api
paths:
/pokemon:
get:
responses:
'200':
description: 200 OK
securityDefinitions:
clientID:
description: ''
in: query
name: client_id
type: apiKey
security:
- clientID: []
x-ibm-configuration:
assembly:
execute:
- invoke:
target-url: $(TestProperty)
properties:
$ref: ./schemas/properties.yaml
gateway: micro-gateway
和相應的參考文件(./schemas/properties.yaml):-
TestProperty:
type: object
value: 'https://pokemons.mybluemix.net/api/pokemons'
description: ''
encoded: false
驗證了這一點,錯誤是不同的。此YAML針對Swagger 2.0版架構API定義和針對IBM Swagger 2.0版架構API定義進行驗證,但不針對API Connect易怒擴展架構API定義進行驗證。
這裏的錯誤信息: -
C:\Users\MyName\TestNotes\definitions>apic validate pokemonapp_1.0.0.yaml
Successfully validated pokemonapp_1.0.0.yaml against Swagger Version 2.0 schema API definition [pokemonapp:1.0.0].
Error validating pokemonapp_1.0.0.yaml with API Connect swagger extensions schema API definition [pokemonapp:1.0.0].
Invalid type: string (expected object) (/properties/$ref)
Successfully validated pokemonapp_1.0.0.yaml against IBM Swagger Version 2.0 schema API definition [pokemonapp:1.0.0].
Error: Validation did not complete successfully.
阿努知道我做錯了嗎? P.S.在這兩種情況下,swagger都會針對'Swagger 2.0版模式API定義'進行驗證。它只是針對IBM不具備的具體模式。
您使用的是什麼版本的APIConnect? 'apic --ext-version' – Rick
apic --ext-version apiconnect:v2.1.19(API Connect:v5.0.2.1) apiconnect-cli-apis 2.1.0 apiconnect-cli-apps 2.1.0 apiconnect-CLI-auth的2.1.6 apiconnect-CLI-目錄2.1.0 apiconnect-CLI-配置2.1.0 apiconnect-CLI創建2.1.1 apiconnect-CLI-草案2.1.0 apiconnect-CLI-編輯2.1.0 apiconnect-CLI環回2.1.3 apiconnect-CLI-機構單位2.1.0 apiconnect-CLI-PM 2.1.0 microgateway 1.2.0 流引擎1.0.3 apiconnect-CLI-政策1.1。 0 apiconnect-c li-products 2.1.0 apiconnect-cli-validate 2.1.0 plugins 3.0.2 –
我希望你不是在製作口袋妖怪去欺騙應用!欺騙是糟糕的。 – MBillau