-
-
Notifications
You must be signed in to change notification settings - Fork 873
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
Reset operations for each resource class and remove api prefix to mak… #613
Conversation
Not sure what changed in the swagger fixtures but my swagger file validates just fine with this code. |
Thanks for testing and fixing this! It's the Swagger file from the test app. You can generate it to debug by running: Ping @Simperfit |
|
||
$itemOperationsDocs = []; | ||
$definitions = []; | ||
$basePath = $this->urlGenerator->generate('api_hydra_entrypoint'); |
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't you pass the ApiPlatform\Core\Api\UrlGeneratorInterface::REL_PATH);
as second parameter and remove the addition at line 167 instead?
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.
Nevermind, it will not work.
@Simperfit how do i fix the swagger json in travis? |
@samvdb The Swagger file generated after your patch isn't valid anymore.
|
I'm currently looking at the swagger file generated after the patch you made |
Yeah i see it now, doesn't seem to be a problem i introduced though :) |
@samvdb It is : |
I propose an easier fix: remove the |
Still doesnt validates my swagger file. ➜ DunglasApiBundle git:(patch-1-swagger) ✗ tests/Fixtures/app/console api:swagger:export > swagger.json (php 7 ofc) |
@samvdb can you provide the full stack trace, it's probably another bug. |
@samvdb, indeed, line 343 must return an empty array, not void like now. Can you change that too? |
Already changed it, still waiting for tests to pass. |
@@ -128,7 +125,7 @@ public function getApiDocumentation() : array | |||
} | |||
|
|||
$range = $this->getRange($propertyMetadata); | |||
if (null === $range) { | |||
if (count($range) === 0) { |
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.
empty($range)
is more performant.
Can you rebase? |
…e swagger basepath work
@dunglas all good now |
LGTM 👍 |
Thank you very much @samvdb! |
Reset operations for each resource class and remove api prefix to mak…
This PR fixes a problem where the generated swagger output was wrong because some resources got tagged incorrectly.
Example:
$operation['item'] and $operation['collection'] are not empty and the next resource has no collection operations defined in it's annotation. Only $operation['item'] will be overriden and thus the swagger documentation would contain output from the previous resource in its collection array.
When prefixing the annotation platform resources like this:
Generated paths in swagger will look like /api/foo and the basepath will be /api for the hydra doc route.
Swagger javascript will construct the url to call like this: /api/api/foo which is invalid.