-
-
Notifications
You must be signed in to change notification settings - Fork 864
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
OpenApi v3 refactor #3407
OpenApi v3 refactor #3407
Conversation
I think we should make all the classes immutable. Mutability makes the code very hard to reason about, when there's so much going on. |
Indeed, many classes aren't good yet there are really at the POC state ^^. I think that the |
Definitely, it sounds like a great (and needed) design improvement. At some point we'll even maybe be able to provide a standalone OpenAPI component (a subtree split of this repo). |
9f443a0
to
04fdfaf
Compare
1187bd9
to
f41833c
Compare
e3035ba
to
1c3c2dd
Compare
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.
Very good job! 👏
@@ -105,6 +105,9 @@ public function create(array $context = []): OpenApi | |||
return new OpenApi($info, $servers, $paths, new Model\Components(new \ArrayObject($schemas), new \ArrayObject(), new \ArrayObject(), new \ArrayObject(), new \ArrayObject(), new \ArrayObject(), new \ArrayObject($securitySchemes)), $securityRequirements); | |||
} | |||
|
|||
/** | |||
* @return array | array |
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.
array | array
doesn't look right... maybe array[]
was intended? or even array{array, array}
(https://phpstan.org/writing-php-code/phpdoc-types#array-shapes)?
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.
indeed it should be array[]
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.
oh wait, I see that since then, $schemas
has been changed from array
to \ArrayObject
... so that would give array{array, \ArrayObject}
for PHPStan (or at this point maybe just remove this phpDoc?)
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.
actually the return has become useless, see #4199
return 0 === strpos($operation['path'], '/') ? $operation['path'] : '/'.$operation['path']; | ||
} | ||
$path = $this->operationPathResolver->resolveOperationPath($resourceShortName, $operation, $operationType, $operationName); | ||
if ('.{_format}' === substr($path, -10)) { |
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.
Hey @soyuka Does there any way to enable defining '.{_format}' per resource, even ApiPlatform\Core\OpenApi\Model\Paths does not contain a setter function, in case we decide to decorate the OpenapiFactory ? I have a resource that should export pdf and docx.
Cheers!
With this rework, I want to improve the developer experience in enhancing our OpenAPI support. By using explicit classes that matches the OpenAPI spec, it should be easier to:
Note that there are some missing features (for example pagination parameters and components) and I wanted to get back some feedbacks before continuing this work as it's a heavy refactor.
I also want to add two new objects (PaginationOptions, OpenApiAuthentificationOptions) to reduce the number of arguments in the constructor.
WDYT ? Should I continue working on this?