apiaryio / api-blueprint

API Blueprint
https://apiblueprint.org
MIT License
8.63k stars 2.14k forks source link

values for enum field from other resource's attribute #431

Closed user0007 closed 5 years ago

user0007 commented 6 years ago

Hello,

how to use resources attribute as values to other enum field? Example:


# Settings (object)
+ languages (array[string])

## User (object)
+ language (enum[Settings.languages]) 
pksunkara commented 6 years ago

It's not possible to reference attributes of another object.

kylef commented 5 years ago

You would have to break out the property definition into a separate data structure. For example:

FORMAT: 1A

# My API

## GET /user

+ Response 200 (application/json)
    + Attributes (User)

## GET /languages

+ Response 200 (application/json)
    + Attributes (Languages)

## Data Structures

### Language (enum)

+ nl
+ de

### Languages

+ languages (array[Language])

### User

+ language (Language)