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
  • #4396
Closed
Open
Issue created Nov 06, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][C++][Pistache] Multipart/related is not handled. No code generated

Created by: CyrilleBenard

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

The use of Multipart/related seems to be ignored by the generator. No code does reference to this content-type and the Json parser is called transparently without takin into account of the Multipart/related

The generated handler corresponding to the request looks like (but no reference to Multipart/related) :

void SMContextsCollectionApi::post_sm_contexts_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {

    // Getting the body param
    
    Inline_object inlineObject;
    
    try {
      nlohmann::json::parse(request.body()).get_to(inlineObject);
      this->post_sm_contexts(inlineObject, response);
    } catch (std::runtime_error & e) {
      //send a 400 error
      response.send(Pistache::Http::Code::Bad_Request, e.what());
      return;
    }
}
openapi-generator version

4.0.0-SNAPSHOT

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  version: 1.0.0
  title: Check generation of pistache
  description: Internal ref filename is check_multipart-related.yaml

servers:
  - url: http://localhost:8080

paths:
  /sm-contexts:
    post:
      summary:  Create SM Context
      tags:
        - SM contexts collection
      operationId: PostSmContexts
      requestBody:
        description: representation of the SM context to be created in the SMF
        required: true
        content:
          multipart/related:
            schema:
              type: object
              properties: # Request parts
                jsonData:
                  $ref: '#/components/schemas/SmContextCreateData'
                binaryDataN1SmMessage:
                  type: string
                  format: binary
            encoding:
              jsonData:
                contentType:  application/json
              binaryDataN1SmMessage:
                contentType:  application/vnd.3gpp.5gnas
                headers:
                  Content-Id:
                    schema:
                      type: string

      responses:
        '200':
          description: Everythings gonna be alright
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RespContent"
        default:
          description: unexpected error

components:
  schemas:
    RespContent:
      type: string

    SmContextCreateData:
      type: object
      properties:
        supi:
          $ref: '#/components/schemas/Supi'
        unauthenticatedSupi:
          type: boolean
          default:  false
    Supi:
      type: string
Command line used for generation

Generate :

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

Just generate and have a look to the file SMContextsCollectionApi.cpp (method post_sm_contexts_handler). See above also

Related issues/PRs

#3512

Suggest a fix

May be get inspiration with what is done in cpprestsdk to handle multipart/form-data see #3512

Assignee
Assign to
Time tracking