swagger-api / swagger-api/swagger-codegen

format: date results in uncompilable C++ Pistache code generated

Open
#9,659 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description
Swagger-codegen version
Swagger declaration file content or url
swagger: "2.0"
info:
  description: ...
  version: 1.1.1
  title: ...

basePath: /path
schemes:
- http

tags:
- name: api
  description: ...

paths:
  /somepath:
    get:
      tags:
      - Get
      summary: ...
      description: ...
      produces:
      - arrayOfobjectContainingString
      responses:
        200:
          description: Successful response
          schema:
            type: array
            items:
              $ref: "#/definitions/theresponse"

definitions:
  theresponse:
    type: object
    description: ...
    required:
      - type
    properties:
      date:
        type: string
        format: date
        description: ...
        example: some String
Steps to reproduce

Go to editor.swagger.io
Paste YAML above
Generate Pistache Server
Unzip the files, open model/Theresponse.cpp. on line 56 you will see the following:
newItem->fromJson(val["date"]);
which is trying to call "fromJson" on a std::string object. which will not compile.

This goes away if in the YAML file I remove "format: date". Not sure if it is directly related to that.

Related issues/PRs
Suggest a fix/enhancement

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 in editor.swagger.io with the provided YAML and generate the Pistache server. Inspect model/Theresponse.cpp around line 56 and trace the generated fromJson call for the date field; done means the generated C++ code compiles while retaining format: date.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.