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

[BUG][php-symfony] phpLegacySupport=false does not seem to generate strongly typed code #3926

Open
rbaarsma opened this issue Sep 20, 2019 · 2 comments

Comments

@rbaarsma
Copy link

Bug Report Checklist

Description

When using the option phpLegacySupport=false, I expect type hinting to be generated in all files, but sadly it isn't. From a quick look at https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java#L346 I deduced that there should be type hinting when legacy support is disabled. Haven't looked very deeply.

openapi-generator version

Latest docker, used this command:

docker run --rm \
  -v ${PWD}:/local openapitools/openapi-generator-cli generate \
  -i /local/doc/swagger.yml \
  -g php-symfony \
  -o /local/src/Swagger
  --additional-properties phpLegacySupport=false
OpenAPI declaration file content or url
swagger: '2.0'
info:
  title: Test
paths:
  /esbm/nesting:
    get:
      tags:
      - esbmodel
      summary: Get nestings
      parameters:
      - in: query
        name: limit
        type: integer
        required: false
      - in: query
        name: q
        type: string
        required: false
      responses:
        '200':
          description: successful operation
          schema:
            type: object
            properties:
              total:
                type: integer
              data:
                type: array
                items:
                  $ref: '#/definitions/Nesting'
      security:
      - esb_auth: []

definitions:
  Nesting:
    type: object
    properties:
      id:
        type: string
        readOnly: true
      _created_at:
        type: string
        format: date-time
      _updated_at:
        type: string
        format: date-time
      name:
        type: string
      job_number:
        type: string
      sequence_number:
        type: integer

##### Command line used for generation

(see above under "openapi-generator version")

##### Steps to reproduce

simply run the command with the given swagger definition. Generates nicely, but no type hinting.

##### Related issues/PRs

none found

##### Suggest a fix

typehint all function arguments and return types. Properly use ex. `?string` when types are nullable. 

Best is to also generate `declare(strict_types=1);` on every file.
@auto-labeler
Copy link

auto-labeler bot commented Sep 20, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@arderyp
Copy link

arderyp commented Feb 28, 2020

when I set the phpLegacySupport option to false, I do see (more) strongly typed code output when using the php-symfony generator. I do not, however, see any difference in output when using this option with the php generator. Am I missing something, is it supposed to only work with php-symfony?

EDIT: see #5480

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

No branches or pull requests

2 participants