swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
17.01k stars 6.03k forks source link

[PHP][Symfony] Enhancements to Symfony generator #5985

Open wing328 opened 7 years ago

wing328 commented 7 years ago
Description

Here are some enhancements for PHP Symfony generator:

Please feel free to reply if you've any other suggestions.

Swagger-codegen version

Latest master

Related issues

https://github.com/swagger-api/swagger-codegen/pull/5973

Suggest a Fix

If anyone wants to work on these enhancements, please reply to let us know.

cc @ksm2

ksm2 commented 7 years ago

I will work on this, as you can see above, I already needed to do some fixes.

naelrashdeen commented 7 years ago

@wing328 Hi, i am having some syntax issues when I generate the Petstore example. Mainly, the syntax errors occur in the interface classes in the API directory. See some of the examples below:

StoreApiInterface.php namespace Swagger\Server\Api; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Swagger\Server\Model\Order; **use maparray<string,int>;** use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

UserApiInterface.php public function createUsersWithArrayInput(**User[]** $body); public function createUsersWithListInput(User[] $body); As far as I know, it is not possible to use array of objects in this way.

PetApiInterface.php namespace Swagger\Server\Api;

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Swagger\Server\Model\Pet; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Swagger\Server\Model\ApiResponse; **use string[];** use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

public function findPetsByStatus(string[] $status); public function findPetsByTags(string[] $tags);

I don't think it is possible to create array of strings this way as well.

You can try to generate the example yourself to get a better understanding of this issue.

I can create a separate issue regarding this matter and create a pull request with the solution to solve this matter.

reyesMoney3 commented 6 years ago

Found a bug where in Validation does not work on nested objects.

A fix would be to add @Assert\Valid() annotation to model properties that are Object Models or array Object Models