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
  • #6566
Closed
Open
Issue created Jun 05, 2020 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[BUG] Return type broken without properties for php

Created by: neclimdul

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

When generating code from a spec that has a schema definition without properties, something is converting it to a generic object. I'm not sure if this affects other generators or just PHP.

This causes a problem for me generating code for Marketo's API which does this. Many of their Schema's are dynamic and populated with fields from your custom objects. This doesn't "work" out of the box with codegen but its not difficult at least in PHP to modify the model interfaces and Serialization to support this. It also looks like #6290 is starting to add this as a generic feature fixing this might be a requirement for supporting edge cases in that.

By flatting it like this though it becomes much more difficult because there isn't a model. Additionally this isn't ideal because the code diverges from the openapi documentation.

For example. in the 3.x branch the return looks like this: * @return \OpenAPI\Client\Model\ModelResponse in 4.x and beyond it looks like this: * @return object

This is the value in returnType so its in docs, apis, etc and can't be fixed in a templates.

openapi-generator version

v4.0.0+

Tested with docker versions v3.3.4, 4.0.0, 4.3.1, and latest. it seems to exist in all releases after v4.0.0

OpenAPI declaration file content

ModelResponse object on https://developers.marketo.com/swagger/swagger-asset.json

Simplified.

swagger: '2.0'
info:
  title: test
  version: 1.0.0
consumes:
  - application/json
produces:
  - application/json
paths: 
  /person:
    post:
      operationId: createPerson
      responses:
        200:
          description: "Success"
          schema:
            "$ref": "#/definitions/ModelResponse"
definitions:
  ModelResponse:
    type: object
Command line used for generation
docker run --rm -v ${PWD}:/local/ openapitools/openapi-generator-cli:v4.3.1 generate \
    -i /local/object_bug.yaml -g php -o /local/.build 
Steps to reproduce
  1. generate code
  2. see object set as return type.
Related issues/PRs

?

Suggest a fix

Always return the documented model.

Assignee
Assign to
Time tracking