在RAML 1.0,API Platform 2.0上创建带有连字符分隔的资源名称“/songs list”的API Notebook时,会出现以下错误:APINotebook Error
API.createClient('client', '9c2861a1-b**b-401e-****-1ec*****b20c', 'testhyphen', '1.0.2');
已成功创建$0=Client
client.songs-list.post[{"msg":"succ"}];
$1=ReferenceError: list is not defined
at eval (eval at <anonymous> (eval at value (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:998504)), <anonymous>:1:14)
at Object.eval (eval at value (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:998504), <anonymous>:3:8)
at e.value (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:998611)
at https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:2212756
at h.run (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:282445)
at p (https://cdn.anypoint.mulesoft.com/artifacts/exchange-ui/main.efc15523965187f6c807.js:1:281939)
at nrWrapper (https://anypoint.mulesoft.com/exchange/9c2861a1-b**b-401e-****-1ec*****b20c/testhyphen/minor/1.0/:1:24554)上述资产的RAML如下,资源名称为“/songs list”:
#%RAML 1.0
title: testhyphen
/songs-list:
post:
body:
application/json:
responses:
200:
body:
application/json:
example: {"messgae": "Success"}如果资源名称不包含"-“(连字符),例如资源为- "/songs",则接口notebook将按预期运行。API Notebook success
API.createClient('client', '9c2861a1-b**b-401e-****-1ec*****b20c', 'testset', '1.0.1');
$0=Client has been successfully created
client.songs.post[{"msg":"succ"}];
Code snippet executed with no results
发布于 2020-07-17 01:01:50
您可以使用此格式成功运行它:
clients['songs-list'].post[{"msg":"succ"}];如果没有这种格式,它会将连字符视为减法运算符。由于APINotebook在JavaScript上运行,并且支持任何JavaScript语法,因此您可以查看如何在JavaScript中执行操作,并且它们应该与APINotebook一起工作。
https://stackoverflow.com/questions/62875017
复制相似问题