-
-
Notifications
You must be signed in to change notification settings - Fork 849
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
WIP: Add "host" and "schema" declaration to Swagger declaration #765
WIP: Add "host" and "schema" declaration to Swagger declaration #765
Conversation
@dunglas can't fetch |
@@ -488,9 +488,13 @@ private function getType(string $type, bool $isCollection, string $className = n | |||
*/ | |||
private function computeDoc(Documentation $documentation, \ArrayObject $definitions, \ArrayObject $paths) : array | |||
{ | |||
/** @var Symfony\Component\Routing\RequestContext $requestContext */ | |||
$requestContext = $this->urlGenerator->getContext(); |
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.
This works, but is wrong as UrlGenerator
doesn't have getContext()
. What would be a better way to do it? /cc @dunglas
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.
OK, anyway, I'll introduce a new interface matching the RequestContext (so, getHost()
and getSchene()
) and inject it here.
If that sounds wrong, please let me know. /cc @dunglas
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.
I'm afraid it will not work in CLI context (using the doc generation 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.
Would configuring the request context not work here as well? We fetch host and scheme here, if they return null, we throw (maybe with a hint what to do).
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.
In my view, it'd be undesirable to introduce yet another half-baked interface. Let's make use of Psr\Http\Message\UriInterface
from PSR-7 😄
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.
@teohhanhui I completely agree with this, how do you recommend to proceed?
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.
Hmm actually there's no need for any interface, because this is implementation-specific. So you can just inject the Symfony RequestContext
.
49837e0
to
49a4a0d
Compare
Any update on this ? |
* @expectedException \ApiPlatform\Core\Exception\RuntimeException | ||
* @expectedExceptionMessage The property "id" of the resource "ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Dummy" can not be required and read-only at the same time. | ||
*/ | ||
public function testNormalizeThrowsExceptionWithAReadOnlyAndRequiredProperty() |
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.
why ?
@Simperfit not currently, I had to decorate the Swagger generator with all the required functionality. |
This is not going to happen in this PR, closing to avoid confusion. |
Please update this template with something that matches your PR