Skip to content

Commit

Permalink
Add group functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
bradfeehan committed May 7, 2014
1 parent 2a083a0 commit 766caf5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@ file is in, rather than the name of the file. It's essentially an
makes the *directory* the package, rather than the *file*.


##### Groups

Files can also be grouped without causing the contents to be nested.
This is useful for organising a large service description. For example,
if there are thousands of operations, you'd have to have that many
files in the `operations` directory. Using groups, the operations can
be grouped logically inside the `operations` directory.

A group is implemented as a directory ending with `.group`. So you
could have `Users.group` containing all the operations relating to
users, etc.

Note that this could cause problems if you wanted to have a key ending
with `.group`. Please let me know by filing a GitHub issue if this
causes you any issues, and we can work out a way to compromise.



### Loading the service description

Expand Down
4 changes: 4 additions & 0 deletions lib/ServiceDescriptionLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,15 @@ protected function loadModular($path)

// Ignore trailing __index.foo
'/^(.*?)(:?\\/?__index)?\\.(:?\\w+)$/',

// Remove path components ending with .group
'#/\\w+\\.group/#',
),
// replacements (corresponding with patterns above)
array(
'',
'\\1',
'/',
),
$file->getPathname()
);
Expand Down
17 changes: 13 additions & 4 deletions tests/Test/System/ServiceDescriptionLoaderSystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,28 @@ public function testLoadingComplexServiceDescription()
$description->getDescription()
);

$operation = $description->getOperation('ComplexOperation');
$complex = $description->getOperation('ComplexOperation');

$this->assertInstanceOf(
'Guzzle\\Service\\Description\\Operation',
$operation
$complex
);

$this->assertSame('ComplexOperation', $operation->getName());
$this->assertSame('ComplexOperation', $complex->getName());

$parameter = $operation->getParam('my_string_parameter');
$parameter = $complex->getParam('my_string_parameter');
$this->assertSame('my_string_parameter', $parameter->getName());
$this->assertSame('string', $parameter->getType());
$this->assertSame('A string parameter', $parameter->getDescription());

$grouped = $description->getOperation('GroupedComplexOperation');

$this->assertInstanceOf(
'Guzzle\\Service\\Description\\Operation',
$grouped
);

$this->assertSame('GroupedComplexOperation', $grouped->getName());
}

public function testLoadingNonModularServiceDescription()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
httpMethod: POST
parameters:
param_1:
description: The first parameter
type: integer
location: query

0 comments on commit 766caf5

Please sign in to comment.