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
  • #414
Closed
Open
Issue created Jun 28, 2018 by Administrator@rootContributor

[C++] Pistache server - ModelBase::toJson prototype is not accorded with its implementation

Created by: CyrilleBenard

Description

The cpp-pistache-server code does not compile anymore (regression). The generator produces two different method prototype between .cpp and .h content :

In model/ModelBase.h :

class  ModelBase
{
public:
    static nlohmann::json toJson(ModelBase const& content );
};

In model/ModelBase.cpp :

nlohmann::json ModelBase::toJson(ModelBase content )
{
    return content.toJson();
}
openapi-generator version

3.1.0-SNAPSHOT

OpenAPI declaration file content or url

All but here is a small example to facilitate ;)

openapi: 3.0.0
info:
  version: 1.0.0
  title: Simple API
  description: A simple API to illustrate OpenAPI concepts

servers:
  - url: https://example.io/v1

components:
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
security:
  - BasicAuth: []

paths:
  /artists:
    get:
      operationId: getList
      description: Returns a list of artists 
      responses:
        '200':
          description: Successfully returned a list of artists
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  required:
                    - username
                  properties:
                    artist_name:
                      type: string
                    artist_genre:
                      type: string
                    albums_recorded:
                      type: integer
                    username:
                      type: string

        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: object
                properties:   
                  message:
                    type: string
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Simple API",
    "description": "A simple API to illustrate OpenAPI concepts"
  },
  "servers": [
    {
      "url": "https://example.io/v1"
    }
  ],
  "components": {
    "securitySchemes": {
      "BasicAuth": {
        "type": "http",
        "scheme": "basic"
      }
    }
  },
  "security": [
    {
      "BasicAuth": []
    }
  ],
  "paths": {
    "/artists": {
      "get": {
        "operationId": "getList",
        "description": "Returns a list of artists",
        "responses": {
          "200": {
            "description": "Successfully returned a list of artists",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "username"
                    ],
                    "properties": {
                      "artist_name": {
                        "type": "string"
                      },
                      "artist_genre": {
                        "type": "string"
                      },
                      "albums_recorded": {
                        "type": "integer"
                      },
                      "username": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
Command line used for generation

openapi-generator-cli.sh generate -i ./openapi.yaml -g cpp-pistache-server -o .

Steps to reproduce

N/A

Related issues/PRs

N/A

Suggest a fix/enhancement

Declare the method in .cpp in the same way than in the header file

nlohmann::json ModelBase::toJson(ModelBase const & content)
{
    return content.toJson();
}

Assignee
Assign to
Time tracking