2016-04-25 85 views
1

我有這個問題,我已經創建了兩個庫定義兩個不同的類型,在這裏,他們是:RAML 1.0 ciclical嵌套包含

Category.raml

#%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

#%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非常瞭解,所以我在某處讀到「使用」應該只在使用某些東西作爲父項時纔會使用,但是我應該怎麼做才能在我的項目中無處不在地重寫所有內容(因爲這發生在任何地方)。

我想過在一個文件中定義類型的基礎,但它只是一個不應該在一起的信息混合,我想知道是否有替代「使用」的重用另一個文件中的類型。

在此先感謝。

回答

1

最簡單的辦法是讓:

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

你不會有循環依賴。

+0

我在最後得出了同樣的結論,我只是不想創建更多的文件,但我想這是正確的方法。 – 8370