Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit 36bca36

Browse files
authored
Merge pull request #59 from vimeo/blueprint-attribute-enum-support
URI segment attributes now have enum support in generated Blueprints.
2 parents d012df0 + 547b6d1 commit 36bca36

10 files changed

Lines changed: 54 additions & 39 deletions

File tree

resources/examples/Showtimes/blueprints/1.0/api.apib

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ FORMAT: 1A
33
# Mill unit test API, Showtimes
44
This is the API Blueprint file for Mill unit test API, Showtimes.
55

6-
It was automatically generated by [Mill](https://github.com/vimeo/mill) on 2017-04-20 11:43:54.
6+
It was automatically generated by [Mill](https://github.com/vimeo/mill) on 2017-04-20 13:56:37.
77

88
# Group Movies
99
## Movies [/movies/{id}]
1010
Information on a specific movie.
1111

1212
### Get a single movie. [GET]
1313
+ Parameters
14-
+ `id` (integer, required) - Movie ID
14+
- `id` (number, required) - Movie ID
1515
+ Response 200 (application/json)
1616
+ Attributes (Movie)
1717
+ Response 304 (application/json)
@@ -22,7 +22,7 @@ Information on a specific movie.
2222
This action requires a bearer token with `delete` scope.
2323

2424
+ Parameters
25-
+ `id` (integer, required) - Movie ID
25+
- `id` (number, required) - Movie ID
2626
+ Response 204 (application/json)
2727
+ Response 404 (application/json)
2828
+ Attributes (Error)
@@ -84,7 +84,7 @@ Information on a specific movie theater.
8484

8585
### Get a single movie theater [GET]
8686
+ Parameters
87-
+ `id` (integer, required) - Theater ID
87+
- `id` (number, required) - Theater ID
8888
+ Response 200 (application/json)
8989
+ Attributes (Theater)
9090
+ Response 304 (application/json)
@@ -95,7 +95,7 @@ Information on a specific movie theater.
9595
This action requires a bearer token with `create` scope.
9696

9797
+ Parameters
98-
+ `id` (integer, required) - Theater ID
98+
- `id` (number, required) - Theater ID
9999
+ Request
100100
+ Headers
101101

@@ -116,7 +116,7 @@ This action requires a bearer token with `create` scope.
116116
This action requires a bearer token with `delete` scope.
117117

118118
+ Parameters
119-
+ `id` (integer, required) - Theater ID
119+
- `id` (number, required) - Theater ID
120120
+ Response 204 (application/json)
121121
+ Response 404 (application/json)
122122
+ Attributes (Error)

resources/examples/Showtimes/blueprints/1.0/resources/Movies.apib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Information on a specific movie.
44

55
### Get a single movie. [GET]
66
+ Parameters
7-
+ `id` (integer, required) - Movie ID
7+
- `id` (number, required) - Movie ID
88
+ Response 200 (application/json)
99
+ Attributes (Movie)
1010
+ Response 304 (application/json)
@@ -15,7 +15,7 @@ Information on a specific movie.
1515
This action requires a bearer token with `delete` scope.
1616

1717
+ Parameters
18-
+ `id` (integer, required) - Movie ID
18+
- `id` (number, required) - Movie ID
1919
+ Response 204 (application/json)
2020
+ Response 404 (application/json)
2121
+ Attributes (Error)

resources/examples/Showtimes/blueprints/1.0/resources/Theaters.apib

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Information on a specific movie theater.
44

55
### Get a single movie theater [GET]
66
+ Parameters
7-
+ `id` (integer, required) - Theater ID
7+
- `id` (number, required) - Theater ID
88
+ Response 200 (application/json)
99
+ Attributes (Theater)
1010
+ Response 304 (application/json)
@@ -15,7 +15,7 @@ Information on a specific movie theater.
1515
This action requires a bearer token with `create` scope.
1616

1717
+ Parameters
18-
+ `id` (integer, required) - Theater ID
18+
- `id` (number, required) - Theater ID
1919
+ Request
2020
+ Headers
2121

@@ -36,7 +36,7 @@ This action requires a bearer token with `create` scope.
3636
This action requires a bearer token with `delete` scope.
3737

3838
+ Parameters
39-
+ `id` (integer, required) - Theater ID
39+
- `id` (number, required) - Theater ID
4040
+ Response 204 (application/json)
4141
+ Response 404 (application/json)
4242
+ Attributes (Error)

resources/examples/Showtimes/blueprints/1.1.1/api.apib

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ FORMAT: 1A
33
# Mill unit test API, Showtimes
44
This is the API Blueprint file for Mill unit test API, Showtimes.
55

6-
It was automatically generated by [Mill](https://github.com/vimeo/mill) on 2017-04-20 11:43:54.
6+
It was automatically generated by [Mill](https://github.com/vimeo/mill) on 2017-04-20 13:56:37.
77

88
# Group Movies
99
## Movies [/movies/{id}]
1010
Information on a specific movie.
1111

1212
### Get a single movie. [GET]
1313
+ Parameters
14-
+ `id` (integer, required) - Movie ID
14+
- `id` (number, required) - Movie ID
1515
+ Response 200 (application/json)
1616
+ Attributes (Movie)
1717
+ Response 304 (application/json)
@@ -22,7 +22,7 @@ Information on a specific movie.
2222
This action requires a bearer token with `edit` scope.
2323

2424
+ Parameters
25-
+ `id` (integer, required) - Movie ID
25+
- `id` (number, required) - Movie ID
2626
+ Request
2727
+ Headers
2828

@@ -63,7 +63,7 @@ This action requires a bearer token with `edit` scope.
6363
This action requires a bearer token with `delete` scope.
6464

6565
+ Parameters
66-
+ `id` (integer, required) - Movie ID
66+
- `id` (number, required) - Movie ID
6767
+ Response 204 (application/json)
6868
+ Response 404 (application/json)
6969
+ Attributes (Error)
@@ -127,7 +127,7 @@ Information on a specific movie theater.
127127

128128
### Get a single movie theater [GET]
129129
+ Parameters
130-
+ `id` (integer, required) - Theater ID
130+
- `id` (number, required) - Theater ID
131131
+ Response 200 (application/json)
132132
+ Attributes (Theater)
133133
+ Response 304 (application/json)
@@ -138,7 +138,7 @@ Information on a specific movie theater.
138138
This action requires a bearer token with `create` scope.
139139

140140
+ Parameters
141-
+ `id` (integer, required) - Theater ID
141+
- `id` (number, required) - Theater ID
142142
+ Request
143143
+ Headers
144144

@@ -159,7 +159,7 @@ This action requires a bearer token with `create` scope.
159159
This action requires a bearer token with `delete` scope.
160160

161161
+ Parameters
162-
+ `id` (integer, required) - Theater ID
162+
- `id` (number, required) - Theater ID
163163
+ Response 204 (application/json)
164164
+ Response 404 (application/json)
165165
+ Attributes (Error)

resources/examples/Showtimes/blueprints/1.1.1/resources/Movies.apib

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Information on a specific movie.
44

55
### Get a single movie. [GET]
66
+ Parameters
7-
+ `id` (integer, required) - Movie ID
7+
- `id` (number, required) - Movie ID
88
+ Response 200 (application/json)
99
+ Attributes (Movie)
1010
+ Response 304 (application/json)
@@ -15,7 +15,7 @@ Information on a specific movie.
1515
This action requires a bearer token with `edit` scope.
1616

1717
+ Parameters
18-
+ `id` (integer, required) - Movie ID
18+
- `id` (number, required) - Movie ID
1919
+ Request
2020
+ Headers
2121

@@ -56,7 +56,7 @@ This action requires a bearer token with `edit` scope.
5656
This action requires a bearer token with `delete` scope.
5757

5858
+ Parameters
59-
+ `id` (integer, required) - Movie ID
59+
- `id` (number, required) - Movie ID
6060
+ Response 204 (application/json)
6161
+ Response 404 (application/json)
6262
+ Attributes (Error)

resources/examples/Showtimes/blueprints/1.1.1/resources/Theaters.apib

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Information on a specific movie theater.
44

55
### Get a single movie theater [GET]
66
+ Parameters
7-
+ `id` (integer, required) - Theater ID
7+
- `id` (number, required) - Theater ID
88
+ Response 200 (application/json)
99
+ Attributes (Theater)
1010
+ Response 304 (application/json)
@@ -15,7 +15,7 @@ Information on a specific movie theater.
1515
This action requires a bearer token with `create` scope.
1616

1717
+ Parameters
18-
+ `id` (integer, required) - Theater ID
18+
- `id` (number, required) - Theater ID
1919
+ Request
2020
+ Headers
2121

@@ -36,7 +36,7 @@ This action requires a bearer token with `create` scope.
3636
This action requires a bearer token with `delete` scope.
3737

3838
+ Parameters
39-
+ `id` (integer, required) - Theater ID
39+
- `id` (number, required) - Theater ID
4040
+ Response 204 (application/json)
4141
+ Response 404 (application/json)
4242
+ Attributes (Error)

resources/examples/Showtimes/blueprints/1.1/api.apib

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ FORMAT: 1A
33
# Mill unit test API, Showtimes
44
This is the API Blueprint file for Mill unit test API, Showtimes.
55

6-
It was automatically generated by [Mill](https://github.com/vimeo/mill) on 2017-04-20 11:43:54.
6+
It was automatically generated by [Mill](https://github.com/vimeo/mill) on 2017-04-20 13:56:37.
77

88
# Group Movies
99
## Movies [/movies/{id}]
1010
Information on a specific movie.
1111

1212
### Get a single movie. [GET]
1313
+ Parameters
14-
+ `id` (integer, required) - Movie ID
14+
- `id` (number, required) - Movie ID
1515
+ Response 200 (application/json)
1616
+ Attributes (Movie)
1717
+ Response 304 (application/json)
@@ -22,7 +22,7 @@ Information on a specific movie.
2222
This action requires a bearer token with `edit` scope.
2323

2424
+ Parameters
25-
+ `id` (integer, required) - Movie ID
25+
- `id` (number, required) - Movie ID
2626
+ Request
2727
+ Headers
2828

@@ -62,7 +62,7 @@ This action requires a bearer token with `edit` scope.
6262
This action requires a bearer token with `delete` scope.
6363

6464
+ Parameters
65-
+ `id` (integer, required) - Movie ID
65+
- `id` (number, required) - Movie ID
6666
+ Response 204 (application/json)
6767
+ Response 404 (application/json)
6868
+ Attributes (Error)
@@ -126,7 +126,7 @@ Information on a specific movie theater.
126126

127127
### Get a single movie theater [GET]
128128
+ Parameters
129-
+ `id` (integer, required) - Theater ID
129+
- `id` (number, required) - Theater ID
130130
+ Response 200 (application/json)
131131
+ Attributes (Theater)
132132
+ Response 304 (application/json)
@@ -137,7 +137,7 @@ Information on a specific movie theater.
137137
This action requires a bearer token with `create` scope.
138138

139139
+ Parameters
140-
+ `id` (integer, required) - Theater ID
140+
- `id` (number, required) - Theater ID
141141
+ Request
142142
+ Headers
143143

@@ -158,7 +158,7 @@ This action requires a bearer token with `create` scope.
158158
This action requires a bearer token with `delete` scope.
159159

160160
+ Parameters
161-
+ `id` (integer, required) - Theater ID
161+
- `id` (number, required) - Theater ID
162162
+ Response 204 (application/json)
163163
+ Response 404 (application/json)
164164
+ Attributes (Error)

resources/examples/Showtimes/blueprints/1.1/resources/Movies.apib

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Information on a specific movie.
44

55
### Get a single movie. [GET]
66
+ Parameters
7-
+ `id` (integer, required) - Movie ID
7+
- `id` (number, required) - Movie ID
88
+ Response 200 (application/json)
99
+ Attributes (Movie)
1010
+ Response 304 (application/json)
@@ -15,7 +15,7 @@ Information on a specific movie.
1515
This action requires a bearer token with `edit` scope.
1616

1717
+ Parameters
18-
+ `id` (integer, required) - Movie ID
18+
- `id` (number, required) - Movie ID
1919
+ Request
2020
+ Headers
2121

@@ -55,7 +55,7 @@ This action requires a bearer token with `edit` scope.
5555
This action requires a bearer token with `delete` scope.
5656

5757
+ Parameters
58-
+ `id` (integer, required) - Movie ID
58+
- `id` (number, required) - Movie ID
5959
+ Response 204 (application/json)
6060
+ Response 404 (application/json)
6161
+ Attributes (Error)

resources/examples/Showtimes/blueprints/1.1/resources/Theaters.apib

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Information on a specific movie theater.
44

55
### Get a single movie theater [GET]
66
+ Parameters
7-
+ `id` (integer, required) - Theater ID
7+
- `id` (number, required) - Theater ID
88
+ Response 200 (application/json)
99
+ Attributes (Theater)
1010
+ Response 304 (application/json)
@@ -15,7 +15,7 @@ Information on a specific movie theater.
1515
This action requires a bearer token with `create` scope.
1616

1717
+ Parameters
18-
+ `id` (integer, required) - Theater ID
18+
- `id` (number, required) - Theater ID
1919
+ Request
2020
+ Headers
2121

@@ -36,7 +36,7 @@ This action requires a bearer token with `create` scope.
3636
This action requires a bearer token with `delete` scope.
3737

3838
+ Parameters
39-
+ `id` (integer, required) - Theater ID
39+
- `id` (number, required) - Theater ID
4040
+ Response 204 (application/json)
4141
+ Response 404 (application/json)
4242
+ Attributes (Error)

src/Generator/Blueprint.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,30 @@ protected function processParameters(Action\Documentation $action)
206206
$field = str_replace($from, $to, $field);
207207
}
208208

209+
$values = $segment->getValues();
210+
$type = $this->convertTypeToCompatibleType($segment->getType());
211+
209212
$blueprint .= $this->tab();
210213
$blueprint .= sprintf(
211-
'+ `%s` (%s, required) - %s',
214+
'- `%s` (%s, required) - %s',
212215
$field,
213-
$segment->getType(),
216+
(!empty($values)) ? 'enum[' . $type . ']' : $type,
214217
$segment->getDescription()
215218
);
216219

217220
$blueprint .= $this->line();
221+
222+
if (!empty($values)) {
223+
$blueprint .= $this->tab(2);
224+
$blueprint .= '+ Members';
225+
$blueprint .= $this->line();
226+
227+
foreach ($values as $value) {
228+
$blueprint .= $this->tab(3);
229+
$blueprint .= '+ `' . $value . '`';
230+
$blueprint .= $this->line();
231+
}
232+
}
218233
}
219234

220235
return $blueprint;

0 commit comments

Comments
 (0)