Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion - Select request body content-type as ordered in OpenAPI #802

Closed
wants to merge 1 commit into from

Conversation

thim81
Copy link
Contributor

@thim81 thim81 commented Jul 10, 2024

Linked to #801

Currently the request body used for creating the Postman request is a fixed content-type mapping, where the following logic applies:

  1. if present, the 'x-www-form-urlencoded' is taken
  2. ELSE if the 'form-data' is taken
  3. ELSE fallback to 'raw'

This PR uses the order of the request body content-types as ordered in the OpenAPI spec, meaning which ever is found first will be taken.

Example OpenAPI:

openapi: 3.0.0
info:
  version: v1
  title: 601-RequestBody TcPCM Gateway API
  description: TcPCM Gateway API
  license:
    name: Privacy Policy
    url: https://www.plm.automation.siemens.com/global/en/legal/privacy-policy.html
paths:
  "/api/v1/administration/samAuth/users/{userName}":
    put:
      tags:
        - "Administration: Users"
      summary: Create or Update Sam Auth User
      operationId: CreateSamAuthUser_CreateOrUpdateSamAuthUser
      parameters:
        - name: userName
          in: path
          description: User name
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: bearer token
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSamAuthUserRequestModel"
          text/json:
            schema:
              $ref: "#/components/schemas/CreateSamAuthUserRequestModel"
          application/xml:
            schema:
              $ref: "#/components/schemas/CreateSamAuthUserRequestModel"
          text/xml:
            schema:
              $ref: "#/components/schemas/CreateSamAuthUserRequestModel"
          application/x-www-form-urlencoded:
            schema:
              $ref: "#/components/schemas/CreateSamAuthUserRequestModel"
        description: The request represents that the user with {userName} will either be
          created or updated depending on whether the {userName} exists or not.
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
            text/json:
              schema:
                type: object
            application/xml:
              schema:
                type: object
            text/xml:
              schema:
                type: object

Current result:
image

PR result:
image

@thim81
Copy link
Contributor Author

thim81 commented Jul 11, 2024

Closing this in favour of #803

@thim81 thim81 closed this Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant