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
  • #637
Closed
Open
Issue created Jul 24, 2018 by Administrator@rootContributor

[C++][Pistache-server] model is not a namespace-name

Created by: CyrilleBenard

Description

The generator seems to add systematically the instruction using namespace xxx::yyy::model ; without any needs and without, at least, one corresponding definition of the model namespace. The C++ compilation failed.

Compilation error looks like

In file included from api/CheckApi.cpp:13:0:
api/CheckApi.h:39:60: error: ‘model’ is not a namespace-name
 using namespace com::bcom::amf::microservice::server::ms1::model;
                                                            ^
api/CheckApi.h:39:65: error: expected namespace-name before ‘;’ token
 using namespace com::bcom::amf::microservice::server::ms1::model;
                                                                 ^
api/CheckApi.cpp:23:60: error: ‘model’ is not a namespace-name
 using namespace com::bcom::amf::microservice::server::ms1::model;
                                                            ^
api/CheckApi.cpp:23:65: error: expected namespace-name before ‘;’ token
 using namespace com::bcom::amf::microservice::server::ms1::model;
                                                                 ^

NOTE : The hierarchical namespace names shown above is mine but the bug issue is non dependent. Using the default namespaces will produce a similar compilation error. If needed, you will find my config.json file content below

openapi-generator version

3.1.2-SNAPSHOT

OpenAPI declaration file content or url
openapi: "3.0.0"
info:
  version: 1.0.0
  title: Check unknown namespace-name model
servers:
  - url: http://localhost:8080
paths:
  /check:
    get:
      summary: blabla
      operationId: list
      tags:
        - Check
      responses:
        '200':
          description: Everythings gonna be alright
          headers:
            x-next:
              description: A link to the next page of responses
              schema:
                type: string
          content:
            application/json:    
              schema:
                $ref: "#/components/schemas/Bytes"
      default:
        description: unexpected error
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Bytes"

components:
  schemas:
    Bytes:
      format: byte
      type: string

    Content:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/Bytes'
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Check unknown namespace-name model"
  },
  "servers": [
    {
      "url": "http://localhost:8080"
    }
  ],
  "paths": {
    "/check": {
      "get": {
        "summary": "blabla",
        "operationId": "list",
        "tags": [
          "Check"
        ],
        "responses": {
          "200": {
            "description": "Everythings gonna be alright",
            "headers": {
              "x-next": {
                "description": "A link to the next page of responses",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Bytes"
                }
              }
            }
          }
        },
        "default": {
          "description": "unexpected error",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Bytes"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Bytes": {
        "format": "byte",
        "type": "string"
      },
      "Content": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/Bytes"
          }
        }
      }
    }
  }
}

config.json :

{
    "modelPackage"   : "com.bcom.amf.microservice.server.ms1.model",
    "apiPackage"     : "com.bcom.amf.microservice.server.ms1.api"
}
Command line used for generation

Generate :

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

Compile :

g++ -c  -I./api -I./model -I./impl -Wall -g -std=c++11 -o obj/api/CheckApi.o api/CheckApi.cpp
Steps to reproduce

Generate & compile

Related issues/PRs

N/A

Suggest a fix/enhancement

In case the generator needs to let this behavior as this, include systematically the ModelBase.h header file ... but I don't think its the best proposal ever seen 🤣 The generator should add the using namespace xxx::yyyy::model only when using, at least, one model class.

Assignee
Assign to
Time tracking