OpenAPITools / OpenAPITools/openapi-generator

[cpp-pistache-server] Bug: not generating all files and methods

Open
#1,637 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

cpp-pistache-server can generate code which does not compile because it's missing files and methods:

- There are files which have `#include "Object.h"` but no `Object.h` file was generated anywhere.
- `model/AsdfInfo.cpp`'s `AsdfInfo::fromJson` includes a call to `setAttributes` but
  no such method was generated for `AsdfInfo`.
openapi-generator version

It's 3.3.4 but I've seen the Object.h issue in 3.3.2 and 3.3.3 though I worked around it temporarily by writing my own Object.h file.
The missing setAttributes call seems to be new in 3.3.4

OpenAPI declaration file content or url

This is the mini.yaml file that reproduces the issue:

openapi: "3.0.0"
info:
  version: "1.0"
  title: An API
paths:
  /asdfs:
    post:
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/asdfInfo'
      responses:
        201:
          description: "Created"
          content:
            application/json:
              schema:
                type: object
                properties:
                  asdfId:
                    type: integer
                    format: int64
components:
  schemas:
    asdfInfo:
      type: object
      properties:
        attributes:
          type: object
Command line used for generation
  • java -version is:
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
  • OS is "CentOS Linux release 7.5.1804 (Core)
  • using Apache Maven 3.3.9
Steps to reproduce

Steps:

  • Ran mvn clean package
  • Using the newly-created modules/openapi-generator-cli/target/openapi-generator-cli.jar
    • Call it $JAR
  • Run java -jar $JAR generate -i mini.yaml -g cpp-pistache-server -o gen_output
    • (mini.yaml is above)
  • Look inside gen_output and notice these issues:
    • There are files which have #include "Object.h" but no Object.h file was generated anywhere.
    • model/AsdfInfo.cpp's AsdfInfo::fromJson includes a call to setAttributes but
      no such method was generated for AsdfInfo.

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 issue with the supplied mini.yaml and the documented java -jar generate command, then inspect the generated model/AsdfInfo.cpp and references to Object.h. Done means the cpp-pistache-server output includes the referenced file and method and compiles without these missing-symbol errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, java
Domain
backend-api-design, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.