首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有对子RAML的引用的主RAML文件

带有对子RAML的引用的主RAML文件
EN

Stack Overflow用户
提问于 2018-02-09 15:15:40
回答 1查看 370关注 0票数 0

我有两个RAML文件(必须是v0.8),完全描述了两个资源: animals.raml和plants.raml。

它们都包含如下内容:

代码语言:javascript
复制
#%RAML 0.8
---
title: Animals API
baseUri: http://something/
documentation:
  - title: Overview
    content: The */animals* resource allows you to...
mediaType: application/json

protocols:
  - HTTPS

/animals:
  post:
    description: Create a new animal
    body:
      schema: !include ./schemas/animal.schema.json
    responses:
      202:
        description: In a few months, your new pet will be born.

现在我想要一个主文件,api.raml,它将提供有关动植物资源的一般概述。API读取器将导航到api.raml,从那里他将能够再次导航到特定的raml。也可以是内联的,在同一页上。

我天真地尝试了

代码语言:javascript
复制
#%RAML 0.8
---
title: Zoo & Botanical garden APIs
documentation:
  - title: Overview
    content: The *Zoo & Botanical garden APIs* contain resources that allow you to ...

resourceTypes: !include animals.raml
resourceTypes: !include plants.raml

显然很天真,失败了,很多关于标题元素的抱怨和其他的抱怨。

我应该如何创建主api.raml,它基本上只需要包含一个通用信息,然后包含/链接到特定的RAML?

EN

回答 1

Stack Overflow用户

发布于 2018-02-09 16:37:20

不能使用"resourceTypes:“关键字两次,您可以将资源类型分开如下:

代码语言:javascript
复制
#%RAML 0.8
title: Example API
version: v1
resourceTypes:
   - collection: !include resourceTypes/collection.raml
   - member: !include resourceTypes/member.raml

或者将所有内容都包含在一个文件中,然后这样做:

代码语言:javascript
复制
#%RAML 0.8
title: Example API
version: v1
resourceTypes: !include resourceTypes.raml

检查有关如何使用的更多信息,请参见

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48708848

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档