Skip to content

Commit

Permalink
default export command to v2 and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
antograssiot committed Dec 21, 2018
1 parent fcd20a0 commit e79519f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions features/openapi/docs.feature
Expand Up @@ -5,7 +5,7 @@ Feature: Documentation support

@createSchema
Scenario: Retrieve the OpenAPI documentation
Given I send a "GET" request to "/docs.json"
Given I send a "GET" request to "/docs.json?spec_version=3"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json; charset=utf-8"
Expand Down Expand Up @@ -89,15 +89,15 @@ Feature: Documentation support

Scenario: OpenAPI UI is enabled for docs endpoint
Given I add "Accept" header equal to "text/html"
And I send a "GET" request to "/docs"
And I send a "GET" request to "/docs?spec_version=3"
Then the response status code should be 200
And I should see text matching "My Dummy API"
And I should see text matching "openapi"
And I should see text matching "3.0.2"

Scenario: OpenAPI UI is enabled for an arbitrary endpoint
Given I add "Accept" header equal to "text/html"
And I send a "GET" request to "/dummies"
And I send a "GET" request to "/dummies?spec_version=3"
Then the response status code should be 200
And I should see text matching "openapi"
And I should see text matching "3.0.2"
6 changes: 3 additions & 3 deletions features/swagger/docs.feature
Expand Up @@ -5,7 +5,7 @@ Feature: Documentation support

@createSchema
Scenario: Retrieve the Swagger/OpenAPI documentation
Given I send a "GET" request to "/docs.json?spec_version=2"
Given I send a "GET" request to "/docs.json"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json; charset=utf-8"
Expand Down Expand Up @@ -89,15 +89,15 @@ Feature: Documentation support

Scenario: Swagger UI is enabled for docs endpoint
Given I add "Accept" header equal to "text/html"
And I send a "GET" request to "/docs?spec_version=2"
And I send a "GET" request to "/docs"
Then the response status code should be 200
And I should see text matching "My Dummy API"
And I should see text matching "swagger"
And I should see text matching "2.0"

Scenario: Swagger UI is enabled for an arbitrary endpoint
Given I add "Accept" header equal to "text/html"
And I send a "GET" request to "/dummies?spec_version=2"
And I send a "GET" request to "/dummies"
Then the response status code should be 200
And I should see text matching "My Dummy API"
And I should see text matching "swagger"
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Symfony/Bundle/Command/SwaggerCommand.php
Expand Up @@ -61,7 +61,7 @@ protected function configure()
->setAliases(['api:swagger:export'])
->setDescription('Dump the OpenAPI documentation')
->addOption('yaml', 'y', InputOption::VALUE_NONE, 'Dump the documentation in YAML')
->addOption('spec-version', null, InputOption::VALUE_OPTIONAL, 'OpenAPI version to use ("2" or "3")', '3')
->addOption('spec-version', null, InputOption::VALUE_OPTIONAL, 'OpenAPI version to use ("2" or "3")', '2')
->addOption('output', 'o', InputOption::VALUE_OPTIONAL, 'Write output to file');
}

Expand Down
12 changes: 6 additions & 6 deletions tests/Bridge/Symfony/Bundle/Command/SwaggerCommandTest.php
Expand Up @@ -41,23 +41,23 @@ protected function setUp()
$this->tester = new ApplicationTester($application);
}

public function testExecuteWithAlias()
public function testExecuteWithAliasVersion3()
{
$this->tester->run(['command' => 'api:swagger:export']);
$this->tester->run(['command' => 'api:swagger:export', '--spec-version' => '3']);

$this->assertJson($this->tester->getDisplay());
}

public function testExecuteOpenApiVersion2()
{
$this->tester->run(['command' => 'api:openapi:export', '--spec-version' => '2']);
$this->tester->run(['command' => 'api:openapi:export']);

$this->assertJson($this->tester->getDisplay());
}

public function testExecuteWithYaml()
public function testExecuteWithYamlVersion3()
{
$this->tester->run(['command' => 'api:swagger:export', '--yaml' => true]);
$this->tester->run(['command' => 'api:swagger:export', '--yaml' => true, '--spec-version' => '3']);

$result = $this->tester->getDisplay();
$this->assertYaml($result);
Expand Down Expand Up @@ -85,7 +85,7 @@ public function testExecuteWithYaml()

public function testExecuteOpenApiVersion2WithYaml()
{
$this->tester->run(['command' => 'api:openapi:export', '--spec-version' => '2', '--yaml' => true]);
$this->tester->run(['command' => 'api:openapi:export', '--yaml' => true]);

$result = $this->tester->getDisplay();
$this->assertYaml($result);
Expand Down

0 comments on commit e79519f

Please sign in to comment.