Skip to content

Incorrect Type when response body is a ref containing array #397

@etherealjoy

Description

@etherealjoy
Description

Whenever the response body is a reference to an array of Models the callback is missing the array but contain just the model

For the valid spec below, the following response is generated for cpp-qt5

void apiTestConfigurationGetSignal(OAITestEndPointConfigResponse* summary);

requests are however not impacted and correctly generated

void apiTestConfigurationGet(QList<OAITestEndPointConfig*>*& oai_test_end_point_config);

same issue with go

func (a *DefaultApiService) ApiTestConfigurationGet(ctx context.Context, testEndPointConfig  \
[]TestEndPointConfig) (TestEndPointConfigResponse, *http.Response, error)

Removing the ref and defining the response as an array with a ref to the model avoids the problem but is not a solution
e.g.

        200:
          description: "Successful response"
          schema:
            type: array
            items:
              $ref: "#/definitions/TestEndPointConfig" 

cpp-qt5

void apiTestConfigurationGetSignal(QList<OAITestEndPointConfig*>* summary);

go

func (a *DefaultApiService) ApiTestConfigurationGet(ctx context.Context, testEndPointConfig \
[]TestEndPointConfig) ([]TestEndPointConfigResponse, *http.Response, error)
openapi-generator version

master
3.1.x

OpenAPI declaration file content or url
---
# This is a sample Swagger spec
swagger: "2.0"
info:
  description: Application Description
  version: 1.0.0
  title: Application
  
host: 0.0.0.0:8080
basePath: /api/v1.0
schemes:
- http

paths:            
  /default/ApiTestSetup: 
    get:
      operationId: apiTestConfigurationGet
      produces:
      - application/json
      consumes:
      - application/json
      parameters : 
      - name : "body"
        in : "body"
        required: true
        schema: 
          $ref: "#/definitions/TestEndPointConfigResponse"      
      responses:
        200:
          description: "Successful response"
          schema: 
            $ref: "#/definitions/TestEndPointConfigResponse"          
        400:
          description: "The request was not successfully executed."           
  
definitions:
  TestEndPointConfig:
    type: "object"
    properties:
      Config:
        type: "object"
        additionalProperties:
          type: "string"

  TestEndPointConfigResponse:
    type: array
    items:
      $ref: "#/definitions/TestEndPointConfig" 
Command line used for generation
java -jar <pathToJar> generate -i ./swagger.yaml  -o ./gengocl -g go
java -jar <pathToJar> generate -i ./swagger.yaml  -o ./gencpp -g cpp-qt5
Related issues/PRs

#362

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions