-
-
Notifications
You must be signed in to change notification settings - Fork 869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: swagger v2 #591
feat: swagger v2 #591
Conversation
* | ||
* @param XmlFileLoader $loader | ||
*/ | ||
private function enableJsonLd(XmlFileLoader $loader) | ||
{ | ||
$loader->load('jsonld.xml'); | ||
$loader->load('hydra.xml'); | ||
$loader->load('swagger.xml'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swagger support is not related to JSON-LD support. You can import the file directly here: https://github.com/Simperfit/core/blob/119af86fdd0ba61090320d73055b3e87d50c2e2a/src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php#L84
First of all, thanks for working on this @Simperfit. It's very much appreciated. Unless JSON-LD, HAL or JSON API, Swagger is just an API documentation format. Not all resources exposed by the API will be available in the "Swagger". There will be only one new URL returning the Swagger doc. Basically, you can keep your |
@dunglas Comments taken in account. I've added a console command that dumps the documentation |
b665c20
to
48997eb
Compare
* | ||
* @author Amrouche Hamza <hamza.simperfit@gmail.com> | ||
*/ | ||
class SwaggerCommand extends Command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this class final
?
When you'll write tests, you can use https://hub.docker.com/r/swaggerapi/swagger-validator/ to validate the generated Swagger file of the test app in Travis. |
{ | ||
/** @var InitializedContextEnvironment $environment */ | ||
$environment = $scope->getEnvironment(); | ||
$this->restContext = $environment->getContext('Sanpi\Behatch\Context\RestContext'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sanpi\Behatch\Context\RestContext::class
?
@@ -60,6 +60,7 @@ public function load($data, $type = null) | |||
|
|||
$routeCollection->addCollection($this->fileLoader->load('jsonld.xml')); | |||
$routeCollection->addCollection($this->fileLoader->load('hydra.xml')); | |||
$routeCollection->addCollection($this->fileLoader->load('swagger.xml')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be loaded only if the config flag is set to true
.
I left some minor comments but it looks good to me. What do you think @api-platform/core-team I want it in the first beta too! |
$propertyInfos = null; | ||
foreach ($properties as $classPropertyName => $property) { | ||
if ($classPropertyName === $propertyName) { | ||
$propertyInfos = $property; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have to iterate over all the properties? Can't we return as soon as we got one?
Can you also add a unit test for the Swagger generator? |
@dunglas I asserted the Json, what do I test ? Like in behat ? |
@Simperfit a PHPUnit test on the class itself would be the best. Can you resolve conflicts too? |
0febd58
to
420deeb
Compare
@dunglas I've added one on the console, |
On the builder. We try to have unit tests for every new classes. |
Thank you @Simperfit |
feat: swagger v2
Since NelmioApiDocBundle is not going to update to swagger v2, we will do it in api-platform.
This is WIP :
I have been doing that today, tested with SwaggerUI by changing the format of hydra / swagger