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

Commit

Permalink
Moving param and uriSegment annotations over to a new MSON syntax. #42
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Ursenbach committed Apr 28, 2017
1 parent be36f8f commit 3bcfe6d
Show file tree
Hide file tree
Showing 20 changed files with 795 additions and 354 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"symfony/console": "^2.8",
"pimple/pimple": "^3.0",
"league/flysystem": "^1.0",
"composer/semver": "^1.4"
"composer/semver": "^1.4",
"gossi/docblock": "^1.5"
},
"require-dev": {
"squizlabs/php_codesniffer": "^2.7",
Expand Down
37 changes: 23 additions & 14 deletions resources/examples/Showtimes/Controllers/Movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Movie
* @api-label Get a single movie.
*
* @api-uri:public {Movies} /movies/+id
* @api-uriSegment {/movies/+id} {integer} id Movie ID
* @api-uriSegment {/movies/+id} id (integer) - Movie ID
*
* @api-contentType application/json
*
Expand All @@ -34,22 +34,31 @@ public function GET()
* @api-label Update a movie.
*
* @api-uri:public {Movies} /movies/+id
* @api-uriSegment {/movies/+id} {integer} id Movie ID
* @api-uriSegment {/movies/+id} id (integer) - Movie ID
*
* @api-contentType application/json
* @api-scope edit
* @api-minVersion 1.1
*
* @api-param:public {string} name Name of the movie.
* @api-param:public {string} description Description, or tagline, for the movie.
* @api-param:public {string} runtime (optional) Movie runtime, in `HHhr MMmin` format.
* @api-param:public {string} content_rating [G|PG|PG-13|R|NC-17|X|NR|UR] (optional) MPAA rating
* @api-param:public {array} genres (optional) Array of movie genres.
* @api-param:public {string} trailer (optional) Trailer URL
* @api-param:public {string} director (optional) Name of the director.
* @api-param:public {array} cast (optional) Array of names of the cast.
* @api-param:public {boolean} is_kid_friendly (optional) Is this movie kid friendly?
* @api-param:public {integer} rotten_tomatoes_score (optional) Rotten Tomatoes score
* @api-param:public name (string, required) - Name of the movie.
* @api-param:public description (string, required) - Description, or tagline, for the movie.
* @api-param:public runtime (string, optional) - Movie runtime, in `HHhr MMmin` format.
* @api-param:public content_rating (string, optional) - MPAA rating
* + Members
* - `G`
* - `PG`
* - `PG-13`
* - `R`
* - `NC-17`
* - `X`
* - `NR`
* - `UR`
* @api-param:public genres (array, optional) - Array of movie genres.
* @api-param:public trailer (string, optional) - Trailer URL
* @api-param:public director (string, optional) - Name of the director.
* @api-param:public cast (array, optional) - Array of names of the cast.
* @api-param:public is_kid_friendly (boolean, optional) - Is this movie kid friendly?
* @api-param:public rotten_tomatoes_score (integer, optional) - Rotten Tomatoes score
*
* @api-return:public {object} \Mill\Examples\Showtimes\Representations\Movie
*
Expand All @@ -59,7 +68,7 @@ public function GET()
* @api-throws:public {404} \Mill\Examples\Showtimes\Representations\Error If the movie could not be found.
*
* @api-version >=1.1.1
* @api-param:public {string} imdb (optional) IMDB URL
* @api-param:public imdb (string, optional) - IMDB URL
*/
public function PATCH()
{
Expand All @@ -72,7 +81,7 @@ public function PATCH()
* @api-label Delete a movie.
*
* @api-uri:private {Movies} /movies/+id
* @api-uriSegment {/movies/+id} {integer} id Movie ID
* @api-uriSegment {/movies/+id} id (integer) - Movie ID
*
* @api-contentType application/json
* @api-scope delete
Expand Down
33 changes: 21 additions & 12 deletions resources/examples/Showtimes/Controllers/Movies.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Movies
*
* @api-contentType application/json
*
* @api-param:public {string} location Location you want movies for.
* @api-param:public location (string) - Location you want movies for.
*
* @api-return:public {collection} \Mill\Examples\Showtimes\Representations\Movie
*
Expand All @@ -36,15 +36,24 @@ public function GET()
* @api-contentType application/json
* @api-scope create
*
* @api-param:public {string} name Name of the movie.
* @api-param:public {string} description Description, or tagline, for the movie.
* @api-param:public {string} runtime (optional) Movie runtime, in `HHhr MMmin` format.
* @api-param:public {string} content_rating [G|PG|PG-13|R|NC-17|X|NR|UR] (optional) MPAA rating
* @api-param:public {array} genres (optional) Array of movie genres.
* @api-param:public {string} director (optional) Name of the director.
* @api-param:public {array} cast (optional) Array of names of the cast.
* @api-param:public {boolean} is_kid_friendly (optional) Is this movie kid friendly?
* @api-param:public {integer} rotten_tomatoes_score (optional) Rotten Tomatoes score
* @api-param:public name (string, required) - Name of the movie.
* @api-param:public name (string, required) - Description, or tagline, for the movie.
* @api-param:public runtime (string, optional) - Movie runtime, in `HHhr MMmin` format.
* @api-param:public content_rating (string, optional) - MPAA rating
* + Members
* - `G`
* - `PG`
* - `PG-13`
* - `R`
* - `NC-17`
* - `X`
* - `NR`
* - `UR`
* @api-param:public genres (array, optional) - Array of movie genres.
* @api-param:public director (string, optional) - Name of the director.
* @api-param:public cast (array, optional) - Array of names of the cast.
* @api-param:public is_kid_friendly (boolean, optional) - Is this movie kid friendly?
* @api-param:public rotten_tomatoes_score (integer, optional) - Rotten Tomatoes score
*
* @api-return:public {object} \Mill\Examples\Showtimes\Representations\Movie
*
Expand All @@ -53,8 +62,8 @@ public function GET()
* @api-throws:public {400} \Mill\Examples\Showtimes\Representations\Error If the IMDB URL could not be validated.
*
* @api-version >=1.1
* @api-param:public {string} imdb (optional) IMDB URL
* @api-param:public {string} trailer (optional) Trailer URL
* @api-param:public imdb (string, optional) - IMDB URL
* @api-param:public trailer (string, optional) - Trailer URL
*/
public function POST()
{
Expand Down
12 changes: 6 additions & 6 deletions resources/examples/Showtimes/Controllers/Theater.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Theater
* @api-label Get a single movie theater
*
* @api-uri:public {Theaters} /theaters/+id
* @api-uriSegment {/theaters/+id} {integer} id Theater ID
* @api-uriSegment {/theaters/+id} id (integer) - Theater ID
*
* @api-contentType application/json
*
Expand All @@ -35,14 +35,14 @@ public function GET()
* @api-label Update a movie theater
*
* @api-uri:public {Theaters} /theaters/+id
* @api-uriSegment {/theaters/+id} {integer} id Theater ID
* @api-uriSegment {/theaters/+id} id (integer) - Theater ID
*
* @api-contentType application/json
* @api-scope create
*
* @api-param:public {string} name Name of the theater.
* @api-param:public {string} address Theater address
* @api-param:public {string} phone_number Theater phone number
* @api-param:public name (string, required) - Name of the theater.
* @api-param:public address (string, required) - Theater address
* @api-param:public phone_number (string, required) - Theater phone number
*
* @api-return:public {object} \Mill\Examples\Showtimes\Representations\Theater
*
Expand All @@ -62,7 +62,7 @@ public function PATCH()
* @api-label Delete a movie movie.
*
* @api-uri:private {Theaters} /theaters/+id
* @api-uriSegment {/theaters/+id} {integer} id Theater ID
* @api-uriSegment {/theaters/+id} id (integer) - Theater ID
*
* @api-contentType application/json
* @api-scope delete
Expand Down
8 changes: 4 additions & 4 deletions resources/examples/Showtimes/Controllers/Theaters.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Theaters
*
* @api-contentType application/json
*
* @api-param:public {string} location Location you want theaters in.
* @api-param:public location (string, required) - Location you want theaters in.
*
* @api-return:public {collection} \Mill\Examples\Showtimes\Representations\Theater
*
Expand All @@ -36,9 +36,9 @@ public function GET()
* @api-contentType application/json
* @api-scope create
*
* @api-param:public {string} name Name of the theater.
* @api-param:public {string} address Theater address
* @api-param:public {string} phone_number Theater phone number
* @api-param:public name (string, required) - Name of the theater.
* @api-param:public address (string, required) - Theater address
* @api-param:public phone_number (string, required) - Theater phone number
*
* @api-return:public {object} \Mill\Examples\Showtimes\Representations\Theater
*
Expand Down
34 changes: 34 additions & 0 deletions src/Exceptions/Resource/Annotations/InvalidMSONSyntaxException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
namespace Mill\Exceptions\Resource\Annotations;

class InvalidMSONSyntaxException extends \Exception
{
use AnnotationExceptionTrait;

/**
* @param string $annotation
* @param string $docblock
* @param string $class
* @param string $method
* @return InvalidMSONSyntaxException
*/
public static function create($required_field, $annotation, $docblock, $class, $method)
{
$message = sprintf(
'Unable to parse a `%s` in the MSON on %s::%s for: `@api-%s %s`',
$required_field,
$class,
$method,
$annotation,
$docblock
);

$exception = new self($message);
$exception->annotation = $annotation;
$exception->docblock = $docblock;
$exception->class = $class;
$exception->method = $method;

return $exception;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class UnsupportedTypeException extends \Exception
public static function create($annotation, $class, $method)
{
$message = sprintf(
'The type on `@api-param %s`in %s::%s is unsupported. Please check the documentation for supported types.',
'The type on `@api-param %s` in %s::%s is unsupported. Please check the documentation for supported types.',
$annotation,
$class,
$method
Expand Down

0 comments on commit 3bcfe6d

Please sign in to comment.