【发布时间】:2020-03-30 09:30:16
【问题描述】:
我在尝试创建 RAML unsing 库来定义 XML 类型时遇到了一些问题。看起来正在将前缀传播到所有属性。
图书馆是这样的:
#%RAML 1.0 Library
types:
book:
type: object
properties:
id:
type: integer
title:
type: string
author:
type: string
xml:
prefix: 'smp'
namespace: 'http://example.com/schema'
name: 'book'
RAML 是这样的:
#%RAML 1.0
title: book test
uses:
myLib: /libraries/types.raml
/book:
description: book
post:
body:
application/xml:
type: myLib.book
这是为 API 发送的 XML:
<?xml version="1.0" encoding="utf-8"?>
<smp:book xmlns:smp="http://example.com/schema">
<id>0</id>
<title>string</title>
<author>string</author>
</smp:book>
我收到了这个错误:
{
"code": "REQUEST_VALIDATION_ERROR",
"message": "Invalid schema for content type application/xml. Errors: cvc-complex-type.2.4.b: The content of element 'smp:book' is not complete. One of '{\"http://example.com/schema\":id, \"http://example.com/schema\":title, \"http://example.com/schema\":author}' is expected.. "
}
【问题讨论】:
-
您还在为此苦苦挣扎吗?如果是这样,我可能会提供帮助
-
是的,这个问题仍然存在。