swagger-api / swagger-api/swagger-codegen

[qt5cpp] Omit JSON-Fields

Open
#6,219 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: C++ General: Question
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

This is just a question, maybe a feature request: I'd like to omit JSON-Fields in the request and don't know how to implement it.

Let's take the sensor_id from the EventSubmitRequest I attached:
In some cases, the sensor_id is maybe not needed.
When I look at the generated sensorId-property in the request-class I see an int that is initialized with '0'.
In my case, if I now send my request, my node-server gets the id '0', but it expects undefined

Is it possible to tell the generated code, that the int-field in this example should be omitted in the request-JSON?

Thanks a lot in advance!

Swagger-codegen version

2.2.3

Swagger declaration file content or url
EventSubmitRequest:
    properties:
      device_id:
        type: integer
        format: int32
      sensor_id:
        type: integer
        format: int32
      created:
        type: string
        format: date-time
      context:
        description: Additional information. E.g. Communication trace
        type: string
      message:
        type: string
      severity:
        type: string
        enum:
          - Debug
          - Info
          - Warning
          - Error

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

The issue mentions the qt5cpp generator and the generated EventSubmitRequest class, but no source file or test is identified. Start by locating the qt5cpp templates and the generated request's JSON serialization, then determine how an unset integer field could be omitted and add coverage for the sensor_id case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.