Skip to content

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

Open
@CyrilleBenard

Description

@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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions