Skip to content

OpenAPI v2 converter: parameter name is lost #748

Open

Description

@jmini

When the parser is doing the conversion from OAS2 to OAS3, a parameter of type in: "body" in OAS2 is converted to a requestBody in OAS3.

Example:

OAS2:

      - name: "requestList"
        in: "body"
        description: "Requests to post"
        required: true
        schema:
          $ref: "#/definitions/listitems"

OAS3:

      requestBody:
        description: Requests to post
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/listitems'
        required: true

During the operation, the parameter name is lost. Would it be possible to have a x-name added to the request body, in order to keep the information of the OAS2?

Expected result after the change?

      requestBody:
        x-name: "requestList"
        description: Requests to post
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/listitems'
        required: true

If you are interested I might be able to propose a PR for that.
Thank you in advance for your answer.


Complete input example:

swagger: "2.0"
info:
  description: Container Application Model Description
  version: 1.0.0
  title: ContainerApplication
  
host: localhost:32000
basePath: /api/v1.0
schemes:
- http

tags:  
- name: ApplicationEndpointTest
  x-displayName: "ApplicationEndpointTest"
  description: |
    "Test of endpoints "
    
paths:
  /default/EndpointTest: 
    post:
      tags:
      - ApplicationEndpointTest      
      description: "post a request"
      operationId: callEndpoint
      consumes:
      - application/json
      parameters:
      - name: "requestList"
        in: "body"
        description: "Requests to post"
        required: true
        schema:
          $ref: "#/definitions/listitems"
      responses:
        200:
          description: "Successful response"
        404:
          description: "The request was not successfully executed."
      
  
definitions:
  listitems : 
    description: "list of items"
    type: array
    items: 
      type: "string"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions