-
Notifications
You must be signed in to change notification settings - Fork 858
Use an !include in a union #713
Comments
!includes cannot participate in a union so your example is invalid. There are several ways to achieve this depending on the structure of your RAML definition(s), one of them is to use a RAML library, e.g.: Library.raml:
Error.raml:
PS: Note that |
I also miss the possibility to do an include in an Union, especially when building datatypes where a value must be either another datatype or nil. Either this could be managed by accepting |
I don't see much of a limitation here since any type can be first defined (in that case by |
May I ask how would you do this so currency can be null or the type Currency? #%RAML 1.0 DataType
type: object
additionalProperties: false
properties:
id: integer
entityId: integer
entityName: string
managingEntityId: integer?
currencyCode: string
currency: any # !include Currency.raml | nil |
You can either turn your fragment into a RAML Library: #%RAML 1.0 Library
types:
Currency:
MyType:
type: object
additionalProperties: false
properties:
id: integer
entityId: integer
entityName:
managingEntityId: integer?
currencyCode:
currency: Currency? # equivalent to: Currency | nil or #%RAML 1.0 DataType
uses:
lib: myLibrary.raml
type: object
additionalProperties: false
properties:
id: integer
entityId: integer
entityName: string
managingEntityId: integer?
currencyCode: string
currency: lib.Currency? # equivalent to: lib.Currency | nil |
After your suggestions, I played a bit with my RAML definitions and used both suggestions. Here are my thoughts:
Currently, the only solution I found is to use a type The solutions I can imagine are:
Here are the example types to illustrate the cyclic dependencies:Address.raml #%RAML 1.0 DataType
type: object
properties:
street: string Customer.raml #%RAML 1.0 DataType
uses:
library: library.raml
type: object
properties:
name: string
address: library.Address | nil library.raml #%RAML 1.0 Library
types:
Address: !include Address.raml
Customer: !include Customer.raml |
I want to create a required, nullable property with a user-defined type in a separate file. How can I accomplish this?
Response.raml
Error.raml
The text was updated successfully, but these errors were encountered: