Skip to content
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

PHP Generator does not generate comma's between string array values #8345

Closed
Klyner007 opened this issue Jun 22, 2018 · 10 comments
Closed

PHP Generator does not generate comma's between string array values #8345

Klyner007 opened this issue Jun 22, 2018 · 10 comments

Comments

@Klyner007
Copy link

Description

When generating a project, the generated models contain array properties which are not formatted right. Between multiple array values there should be a comma but it is not there.

Swagger-codegen version

3.0.0 SNAPSHOT

@HugoMario
Copy link
Contributor

Hello @Klyner007 , can you please check an example of your output? Also if it's possible for you to share the spec you used it would be helpful too.

@Klyner007
Copy link
Author

Klyner007 commented Jun 29, 2018

An example of what the generator generated, is the following:

/**
  * Array of property to type mappings. Used for (de)serialization
  *
  * @var string[]
  */
protected static $swaggerTypes = [
    'uri' => 'string',
	'versions' => '\Swagger\Client\Model\Version[]'
];

I think this is default code which is not in the yml file I imported.

@richjenks
Copy link

richjenks commented Jul 11, 2018

I can reproduce this bug on https://editor.swagger.io and latest release 3.6.3

Spec:

openapi: 3.0.0
info:
  title: vzaar
  description: Swagger document for generating vzaar's SDKs
  version: "2.0"
servers:
  - url: https://vzaar.com/api/v2
paths:
  /videos:
    get:
      summary: Returns a list of videos.
      description: Get videos in account with optional filter and sorting
      responses:
        '200':
          description: A JSON array of videos
          content:
            application/json:
              schema: 
                $ref: '#/components/schemas/Video'
components:
  schemas:
      Video:
        type: object
        properties:
          id:
            type: integer
            example: 123
          title:
            type: string
            example: "My Video"
          description:
            type: string
            example: "Video Description"

lib/model/Video.php:67 is an example where the array has been generated without comma separators:

protected static $swaggerTypes = [
    'id' => 'int''title' => 'string''description' => 'string'
];

In short, component references are broken and when you try to use the client you get a PHP syntax error.

@HugoMario
Copy link
Contributor

hey @Klyner007 @richjenks

i think this was fixed for recent codegen 3.0.0-SNAPSHOT but this version is still not used for editor. however can you please check and let me knnow if it still present? thanks!

@hampsterx
Copy link

@HugoMario half fixed~

3.0.0-SNAPSHOT/swagger-codegen-cli-3.0.0-20180710.190537-87.jar

 protected static $swaggerTypes = [
        'id' => 'int',
        'title' => 'string',
        'description' => 'string'
    ];

but still busted here..

  protected static $attributeMap = [
        'id' => 'id''title' => 'title''description' => 'description'
    ];

@bnowak
Copy link

bnowak commented Dec 10, 2018

Hi,
Any news here?

I have similar problem in version 3.0.3. It's not generate commas properly in method parameters:
java -jar swagger-codegen-cli-3.0.3.jar generate -i https://developer.allegro.pl/swagger.yaml -o . -l php --type-mappings BigDecimal=integer

generated code:

    /**
     * Operation changePublicationStatusUsingPUT
*
     * Modify multiple offers publication at once.
*
* @param  \GreenCell\AllegroRestApiClient\Model\PublicationChangeCommandDto $body publicationChangeCommandDto (required)
* @param  string $commandId commandId (required)
*
     * @throws \GreenCell\AllegroRestApiClient\ApiException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \GreenCell\AllegroRestApiClient\Model\GeneralReport
     */
    public function changePublicationStatusUsingPUT($body$commandId)
    {
        list($response) = $this->changePublicationStatusUsingPUTWithHttpInfo($body$commandId);
        return $response;
    }

Do you know anything about this problem? How now can I modify templates for php? - I don't see any directory with templates in 3.x version.

@joneiros
Copy link

joneiros commented Jan 16, 2019

@bnowak (Solution may only apply to Spring/SpringBoot). It's not great, but it looks like this problem was introduced after 3.0.0. Try reverting version back from 3.0.3 to 3.0.0 and see if this is fixed for you.

@HugoMario
Copy link
Contributor

@hampsterx , can you please check again? i checked this for 3.0.4 and it's fixed. going to close it but let me know if the issue is still present and i'll work on it.

@zefj
Copy link

zefj commented Feb 19, 2019

@HugoMario are you sure it's fixed? I'm running swaggerapi/swagger-codegen-cli-v3:3.0.4 Docker container and just got this exact issue. Generated code:

public function method($body$arg1, $arg2, $arg3)

EDIT: just updated my container, it's fixed in 3.0.5

@bnowak
Copy link

bnowak commented Feb 26, 2019

it works in 3.0.5
thanks 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants