Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #4288
Closed
Open
Issue created Oct 27, 2019 by Administrator@rootContributor

[REQ][PHP] Add toPhpDefinition method to AbstractPhpCodegen

Created by: ybelenko

Is your feature request related to a problem? Please describe.

I've spend some time under php mock server #3545 (closed) At first I analyzed current PHP client implementation. It uses flatten data type declarations, eg string[]. It would be enough for a Mock server, but it doesn't help with automatic request validation. Let's look at the example:

ImageUrls:
  type: array
  minItems: 1
  items:
    type: string
    format: uuid
    minLength: 5
    maxLength: 255

In current implementation this property will be described as:

/** @var string[] $imageUrls */
$imageUrls = [];

As a result we lost minItems, format, minLength and maxLength declarations. It makes automatic request validation impossible. It's obvious that we need all the props to check request under all requirements. The only way I see it we need to serialize all request parameters into PHP arrays. So the model above will look like:

$parameters = [
    'ImageUrls' => [
        'type' => 'array',
        'minItems' => 1,
        'items' => [
            'type' => 'string',
            'format' => 'uuid',
            'minLength' => 5,
            'maxLength' => 255,
        ],
    ],
];

Describe the solution you'd like

I think there should be method in AbstractPhpCodegen to convert Java Map/List instance into PHP array. Then I can convert parameters into PHP strings and add them to codegen, then use it in templates like $parameters = {{serializedParameters}};. Maybe this function/helper can be useful in other cases which I don't even realize yet.

Describe alternatives you've considered

If there is built-in Java method to convert any Java Map/List into PHP string definition please correct me.

cc @jebentier, @dkarlovi, @mandrean, @jfastnacht, @ackintosh, @renepardon

Assignee
Assign to
Time tracking