首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RAML 1.0循环嵌套包括

RAML 1.0循环嵌套包括
EN

Stack Overflow用户
提问于 2016-04-25 03:04:43
回答 1查看 409关注 0票数 1

我有这个问题,我创建了两个库来定义两种不同的类型,如下所示:

Category.raml

代码语言:javascript
复制
#%RAML 1.0 Library
uses:
  - Event: !include Event.raml
  - Tournament: !include Tournament.raml

types:
#############################################################################
    base:
    usage: The base type for a category
    properties:
      min_age:
        description: The minimum age to participate in the category
        required: true
        type: number
      max_age:
        description: The maximum age to participate in the category
        required: true
        type: number
      name:
        description: The name of the category
        required: true
        type: string
      gender:
        description: The gender of the category
        required: true
        enum:
          - male
          - female
          - mix
      tournament:
        description: The tournament of the category
        required: true
        type: Tournament.base
  #############################################################################
  full:
    usage: A category with all of its events
    type: base
    properties:
      events:
        description: The events that the category contains
        required: true
        type: Event.base[]

Tournament.raml

代码语言:javascript
复制
#%RAML 1.0 Library
uses:
  - ClubInscription:  !include Club.raml
  - Category:         !include Category.raml

types:
  #############################################################################
  base:
    usage: The base type for the tournament
    properties:
      name:
        description: The name of the tournament
        required: true
        type: string
      date:
        description: Date of the tournament
        required: true
        type: string
      available_lanes:
        description: Maximum number of lanes in a serie
        required: true
        type: number
      max_swimmer_inscriptions:
        description: Maximum number of events a swimmer may be inscripted
        required: true
        type: number
      award_type:
        description: The type of awarding used in the competition
        required: true
        enum:
          - points
          - medals
          - none
      state:
        description: The current state of the tournament
        required: true
        enum:
          - closed
          - open
          - finished
  #############################################################################
  full:
    usage: A tournament with all its categories and club inscriptions
    type: base
    properties:
      club_inscriptions:
        description: The clubs inscripted in the tournament
        required: true
        type: ClubInscription.base[]
      categories:
        description: The categories the tournament has
        required: true
        type: Category.base[]

有了这个,有冲突是有意义的。我在RAML非常熟悉,所以我在某个地方读到“使用”只应该在使用某物作为父母时使用,但是我应该做什么来避免在我的项目中的任何地方重写所有的东西(因为在项目中的任何地方都会发生这种情况)。

我曾经想过在一个文件中定义类型的基,但是它只是一个不应该在一起的信息的混合,我想知道是否有一种替代“使用”的方法来重复使用另一个文件中的类型。

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-28 15:05:19

最简单的解决办法是:

  • TournamentBase.raml
  • TournamentFull.raml
  • CategoryBase.raml
  • CategoryFull.raml

您将没有循环依赖项。

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

https://stackoverflow.com/questions/36831382

复制
相关文章

相似问题

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