swagger-api / swagger-api/swagger-codegen

PHP array schema bug

Open
#9,356 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Created model for ErrorItemsVas has empty constructor and has no getters/setter, model wasnt treated as model for arrays (didnt contain [] in model name). When I removed this schema and replaced ref with its contents I was able to generate a correct model.

Swagger-codegen version

was using this docker container: swaggerapi/swagger-codegen-cli-v3:3.0.7

Swagger declaration file content or url

schema

ErrorItemsVas:
  type: array
  description: 'Список идентификаторов, которые не удалось обработать по разным причинам (например, они не принадлежат текущему пользователю)'
  items:
    type: integer

usage

  responses:
    '200':
      x-examples:
        application/json:
          vas:
            '1163461995':
              premium: 419
              vip: 179
              pushup: 119
              highlight: 119
              xl: 199
          errors:
            - '1358611169'
      description: Успешный ответ
      content:
        application/json:
          schema:
            type: object
            properties:
              vas:
                $ref: '#/components/schemas/PriceInfoVas'
              errors:
                $ref: '#/components/schemas/ErrorItemsVas'
Command line used for generation

I was also using this params in my config file:
"modelPackage": "Model", "apiPackage": "Api", "invokerPackage": "my\\project\\path"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the generated PHP model from the ErrorItemsVas array schema using swaggerapi/swagger-codegen-cli-v3:3.0.7 and the listed modelPackage and apiPackage settings. No source file or test is named; done means the referenced array schema generates a usable model with the expected constructor and getters/setters.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.