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

Commit

Permalink
Scopes will now carry with @api-see annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Ursenbach committed May 26, 2018
1 parent fab58e7 commit cfe90af
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 42 deletions.
1 change: 1 addition & 0 deletions resources/examples/Showtimes/Representations/Movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function create()
'showtimes' => $this->getShowtimes(),

/**
* @api-scope public
* @api-data external_urls (object) - External URLs
* @api-version >=1.1
* @api-see self::getExternalUrls external_urls
Expand Down
8 changes: 4 additions & 4 deletions resources/examples/Showtimes/blueprints/1.1.1/api.apib
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ This action requires a bearer token with the `create` scope.
+ `X`
- `description` (string) - Description
- `director` (Person) - Director. This data requires a bearer token with the `public` scope.
- `external_urls` (object) - External URLs
- `imdb` (string) - IMDB URL
- `tickets` (string) - Tickets URL
- `trailer` (string) - Trailer URL
- `external_urls` (object) - External URLs. This data requires a bearer token with the `public` scope.
- `imdb` (string) - IMDB URL. This data requires a bearer token with the `public` scope.
- `tickets` (string) - Tickets URL. This data requires a bearer token with the `public` scope.
- `trailer` (string) - Trailer URL. This data requires a bearer token with the `public` scope.
- `genres` (array[string]) - Genres
- `id` (number) - Unique ID
- `kid_friendly`: `false` (boolean) - Kid friendly?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
+ `X`
- `description` (string) - Description
- `director` (Person) - Director. This data requires a bearer token with the `public` scope.
- `external_urls` (object) - External URLs
- `imdb` (string) - IMDB URL
- `tickets` (string) - Tickets URL
- `trailer` (string) - Trailer URL
- `external_urls` (object) - External URLs. This data requires a bearer token with the `public` scope.
- `imdb` (string) - IMDB URL. This data requires a bearer token with the `public` scope.
- `tickets` (string) - Tickets URL. This data requires a bearer token with the `public` scope.
- `trailer` (string) - Trailer URL. This data requires a bearer token with the `public` scope.
- `genres` (array[string]) - Genres
- `id` (number) - Unique ID
- `kid_friendly`: `false` (boolean) - Kid friendly?
Expand Down
8 changes: 4 additions & 4 deletions resources/examples/Showtimes/blueprints/1.1.2/api.apib
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ This action requires a bearer token with the `create` scope.
+ `X`
- `description` (string) - Description
- `director` (Person) - Director. This data requires a bearer token with the `public` scope.
- `external_urls` (object) - External URLs
- `imdb` (string) - IMDB URL
- `tickets` (string) - Tickets URL
- `trailer` (string) - Trailer URL
- `external_urls` (object) - External URLs. This data requires a bearer token with the `public` scope.
- `imdb` (string) - IMDB URL. This data requires a bearer token with the `public` scope.
- `tickets` (string) - Tickets URL. This data requires a bearer token with the `public` scope.
- `trailer` (string) - Trailer URL. This data requires a bearer token with the `public` scope.
- `genres` (array[string]) - Genres
- `id` (number) - Unique ID
- `kid_friendly`: `false` (boolean) - Kid friendly?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
+ `X`
- `description` (string) - Description
- `director` (Person) - Director. This data requires a bearer token with the `public` scope.
- `external_urls` (object) - External URLs
- `imdb` (string) - IMDB URL
- `tickets` (string) - Tickets URL
- `trailer` (string) - Trailer URL
- `external_urls` (object) - External URLs. This data requires a bearer token with the `public` scope.
- `imdb` (string) - IMDB URL. This data requires a bearer token with the `public` scope.
- `tickets` (string) - Tickets URL. This data requires a bearer token with the `public` scope.
- `trailer` (string) - Trailer URL. This data requires a bearer token with the `public` scope.
- `genres` (array[string]) - Genres
- `id` (number) - Unique ID
- `kid_friendly`: `false` (boolean) - Kid friendly?
Expand Down
6 changes: 3 additions & 3 deletions resources/examples/Showtimes/blueprints/1.1.3/api.apib
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ This action requires a bearer token with the `create` scope.
+ `X`
- `description` (string) - Description
- `director` (Person) - Director. This data requires a bearer token with the `public` scope.
- `external_urls` (object) - External URLs
- `imdb` (string) - IMDB URL
- `trailer` (string) - Trailer URL
- `external_urls` (object) - External URLs. This data requires a bearer token with the `public` scope.
- `imdb` (string) - IMDB URL. This data requires a bearer token with the `public` scope.
- `trailer` (string) - Trailer URL. This data requires a bearer token with the `public` scope.
- `genres` (array[string]) - Genres
- `id` (number) - Unique ID
- `kid_friendly`: `false` (boolean) - Kid friendly?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
+ `X`
- `description` (string) - Description
- `director` (Person) - Director. This data requires a bearer token with the `public` scope.
- `external_urls` (object) - External URLs
- `imdb` (string) - IMDB URL
- `trailer` (string) - Trailer URL
- `external_urls` (object) - External URLs. This data requires a bearer token with the `public` scope.
- `imdb` (string) - IMDB URL. This data requires a bearer token with the `public` scope.
- `trailer` (string) - Trailer URL. This data requires a bearer token with the `public` scope.
- `genres` (array[string]) - Genres
- `id` (number) - Unique ID
- `kid_friendly`: `false` (boolean) - Kid friendly?
Expand Down
8 changes: 4 additions & 4 deletions resources/examples/Showtimes/blueprints/1.1/api.apib
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ This action requires a bearer token with the `create` scope.
+ `X`
- `description` (string) - Description
- `director` (Person) - Director. This data requires a bearer token with the `public` scope.
- `external_urls` (object) - External URLs
- `imdb` (string) - IMDB URL
- `tickets` (string) - Tickets URL
- `trailer` (string) - Trailer URL
- `external_urls` (object) - External URLs. This data requires a bearer token with the `public` scope.
- `imdb` (string) - IMDB URL. This data requires a bearer token with the `public` scope.
- `tickets` (string) - Tickets URL. This data requires a bearer token with the `public` scope.
- `trailer` (string) - Trailer URL. This data requires a bearer token with the `public` scope.
- `genres` (array[string]) - Genres
- `id` (number) - Unique ID
- `kid_friendly`: `false` (boolean) - Kid friendly?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
+ `X`
- `description` (string) - Description
- `director` (Person) - Director. This data requires a bearer token with the `public` scope.
- `external_urls` (object) - External URLs
- `imdb` (string) - IMDB URL
- `tickets` (string) - Tickets URL
- `trailer` (string) - Trailer URL
- `external_urls` (object) - External URLs. This data requires a bearer token with the `public` scope.
- `imdb` (string) - IMDB URL. This data requires a bearer token with the `public` scope.
- `tickets` (string) - Tickets URL. This data requires a bearer token with the `public` scope.
- `trailer` (string) - Trailer URL. This data requires a bearer token with the `public` scope.
- `genres` (array[string]) - Genres
- `id` (number) - Unique ID
- `kid_friendly`: `false` (boolean) - Kid friendly?
Expand Down
6 changes: 6 additions & 0 deletions src/Parser/Representation/RepresentationParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ public function parseAnnotations(array $tags, string $original_content): array
}
}

// If this `@api-see` is being used with `@api-scope` annotations, the scope should filter down
// the pipe.
if (!empty($scopes)) {
$annotation->setScopes($scopes);
}

// If this `@api-see` has a prefix to attach to found annotation identifiers, do so.
if (!empty($prefix)) {
$see_annotations[$prefix . '.' . $name] = $annotation->setIdentifierPrefix($prefix);
Expand Down
56 changes: 48 additions & 8 deletions tests/Parser/Representation/DocumentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ public function providerParseDocumentationReturnsRepresentation(): array
'identifier' => 'external_urls',
'nullable' => false,
'sample_data' => false,
'scopes' => [],
'scopes' => [
[
'description' => false,
'scope' => 'public'
]
],
'subtype' => false,
'type' => 'object',
'values' => [],
Expand All @@ -153,7 +158,12 @@ public function providerParseDocumentationReturnsRepresentation(): array
'identifier' => 'external_urls.imdb',
'nullable' => false,
'sample_data' => false,
'scopes' => [],
'scopes' => [
[
'description' => false,
'scope' => 'public'
]
],
'subtype' => false,
'type' => 'string',
'values' => [],
Expand All @@ -165,7 +175,12 @@ public function providerParseDocumentationReturnsRepresentation(): array
'identifier' => 'external_urls.tickets',
'nullable' => false,
'sample_data' => false,
'scopes' => [],
'scopes' => [
[
'description' => false,
'scope' => 'public'
]
],
'subtype' => false,
'type' => 'string',
'values' => [],
Expand All @@ -179,7 +194,12 @@ public function providerParseDocumentationReturnsRepresentation(): array
'identifier' => 'external_urls.trailer',
'nullable' => false,
'sample_data' => false,
'scopes' => [],
'scopes' => [
[
'description' => false,
'scope' => 'public'
]
],
'subtype' => false,
'type' => 'string',
'values' => [],
Expand Down Expand Up @@ -389,7 +409,12 @@ public function providerParseDocumentationReturnsRepresentation(): array
'identifier' => 'external_urls',
'nullable' => false,
'sample_data' => false,
'scopes' => [],
'scopes' => [
[
'description' => false,
'scope' => 'public'
]
],
'subtype' => false,
'type' => 'object',
'values' => [],
Expand All @@ -402,7 +427,12 @@ public function providerParseDocumentationReturnsRepresentation(): array
'identifier' => 'external_urls.imdb',
'nullable' => false,
'sample_data' => false,
'scopes' => [],
'scopes' => [
[
'description' => false,
'scope' => 'public'
]
],
'subtype' => false,
'type' => 'string',
'values' => [],
Expand All @@ -416,7 +446,12 @@ public function providerParseDocumentationReturnsRepresentation(): array
'identifier' => 'external_urls.tickets',
'nullable' => false,
'sample_data' => false,
'scopes' => [],
'scopes' => [
[
'description' => false,
'scope' => 'public'
]
],
'subtype' => false,
'type' => 'string',
'values' => [],
Expand All @@ -432,7 +467,12 @@ public function providerParseDocumentationReturnsRepresentation(): array
'identifier' => 'external_urls.trailer',
'nullable' => false,
'sample_data' => false,
'scopes' => [],
'scopes' => [
[
'description' => false,
'scope' => 'public'
]
],
'subtype' => false,
'type' => 'string',
'values' => [],
Expand Down
28 changes: 24 additions & 4 deletions tests/Parser/Representation/RepresentationParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,12 @@ public function providerParseAnnotations(): array
'identifier' => 'external_urls',
'nullable' => false,
'sample_data' => false,
'scopes' => [],
'scopes' => [
[
'description' => false,
'scope' => 'public'
]
],
'subtype' => false,
'type' => 'object',
'values' => [],
Expand All @@ -267,7 +272,12 @@ public function providerParseAnnotations(): array
'identifier' => 'external_urls.imdb',
'nullable' => false,
'sample_data' => false,
'scopes' => [],
'scopes' => [
[
'description' => false,
'scope' => 'public'
]
],
'subtype' => false,
'type' => 'string',
'values' => [],
Expand All @@ -279,7 +289,12 @@ public function providerParseAnnotations(): array
'identifier' => 'external_urls.tickets',
'nullable' => false,
'sample_data' => false,
'scopes' => [],
'scopes' => [
[
'description' => false,
'scope' => 'public'
]
],
'subtype' => false,
'type' => 'string',
'values' => [],
Expand All @@ -293,7 +308,12 @@ public function providerParseAnnotations(): array
'identifier' => 'external_urls.trailer',
'nullable' => false,
'sample_data' => false,
'scopes' => [],
'scopes' => [
[
'description' => false,
'scope' => 'public'
]
],
'subtype' => false,
'type' => 'string',
'values' => [],
Expand Down

0 comments on commit cfe90af

Please sign in to comment.