2016-04-25 2 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, поэтому я где-то читал, что «use» следует использовать только при использовании чего-то в качестве родителя, но тогда что мне делать, чтобы не переписывать все в любом месте моего проекта (потому что это происходит повсюду в нем).

Я думал об определении базы типов в одном файле, но это было бы просто сочетание информации, которая не должна быть вместе, я хочу знать, есть ли альтернатива «использованию» для повторного использования типы в другом файле.

Заранее спасибо.

ответ

1

Самое простое решение сделать:

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

Вы не будете иметь циклических зависимостей.

+0

Я пришел к такому же выводу в конце, я просто хотел не создавать больше файлов, чем необходимо, но я думаю, что это правильный путь. – 8370

Смежные вопросы