Skip to content

Empty parameters appearing in API call when x-www-urlencoded is used #5314

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

Closed
archivelm opened this issue Apr 19, 2019 · 2 comments
Closed

Comments

@archivelm
Copy link

archivelm commented Apr 19, 2019

Q&A

  • OS: Windows
  • Browser: Chrome, Mozilla
  • Version: Version 73.0.3683.103 (Official Build) (64-bit)
  • Method of installation:
  • Swagger-UI version: master (3.22.1)
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Recently, in our company, we switched from Swagger 2.0 to OpenApi 3.0.0.
We are sending requests via x-www-form-urlencoded where we have a list of parameters.
Not all of these parameters are needed, but they get included in our CURL call.
This is making an issue and essentially our API calls are not working.

Example call:
curl -X POST "https://.../demo/userapi/V3/tasks/create/" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d "external_id_1=&notes=&target_duration=&external_id_2=&external_id_3=&approve_by_project_leader=&restrict_tracking_from_to=&name=Some%20name&sort_order=2&client_id=&user_id=&duration=&mother_id=1&is_done=&is_blocked=&deadline=&is_hidden_create=&individual_value_1=&team_id=&individual_value_2=&individual_value_3="

The correct one should look like:
curl -X POST "https://.../demo/userapi/V3/tasks/create/" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d "name=Some%20name&sort_order=2&mother_id=1"

Essentially, we do not need empty parameters in our calls.
We spent some time looking at the support forums and documentation but didn't find a way to configure this.

Example Swagger/OpenAPI definition:

tasks:
      type: object
      title: Tasks
      properties: 
        id:
          type: integer
        mother_id:
          type: integer
        view_id:
          type: string
        sort_order:
          type: integer
        node_path:
          type: string
        ultimate_mother_id:
          type: integer
        name:
          type: string
        is_done:
          type: boolean
        view_order:
          type: number
        icon_name:
          type: string
        initial_duration:
          type: number
        target_duration:
          type: integer
        begin:
          type: string
          format: date
        deadline:
          type: string
          format: date
        object_type:
          type: string
        notes:
          type: string
        client_id:
          type: integer
        t_iv_1:
          type: string
        t_iv_2:
          type: string
        t_iv_3:
          type: string
        t_iv_4:
          type: string
        t_iv_5:
          type: string
        t_iv_6:
          type: string
        approve_by_project_leader:
          type: boolean
        is_blocked:
          type: boolean
        is_hidden:
          type: boolean
        restrict_tracking_from_to:
          type: boolean
        duration:
          type: integer

  '/userapi/V3/tasks/create/':
    post:
      tags:
        - tasks
      summary: Creates the tasks objects using a POST API call.
      operationId: tasksPostCreate
      requestBody:
        description: "Create tasks based on parameters below"
        required: false
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/tasks_create'
          
      responses: 
        '200': 
          description: Executed successfully
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/tasks'
        '401': 
          description: Unauthorized access.
        '403': 
          description: No permission for this specific endpoint.
        '410': 
          description: Endpoint not available - This API endpoint existed in previous API versions, but not in a current version
        '487': 
          description: Endpoint not available - Account migration / maintenance
        '497': 
          description: Refresh token has been expired, deleted or tried to issue a new access token with the refresh token but for a different user
        '500': 
          description: Server (internal) error
        '503': 
          description: Service Unavailable - Common causes are a server that is down for maintenance or overloaded

Swagger-UI configuration options:

 $(document).ready(function () {
        // Build a system
        const editor = SwaggerUIBundle({
            dom_id: '#swagger',
            layout: 'BaseLayout', // StandaloneLayout
			docExpansion: 'none',
            url: '{{ absolute_url(asset('swagger_files/')) }}{{ requested_version }}.yaml',
            //supportedSubmitMethods: [],
            presets: [
				SwaggerUIBundle.presets.apis,
				SwaggerUIBundle.SwaggerUIStandalonePreset
            ],
            onComplete: function() {
                $('#swagger').removeClass('not-display');
                $('#loader-wrapper').remove();
            }
        });
    });

Describe the bug you're encountering

To reproduce...

API is not publicly available at the moment.
You can import yaml part in a working OpenApi 3.0 and try to execute a test call.

Expected behavior

Provided in a description. Essentially, API calls without empty parameters.

Additional context or thoughts

Might this be some kind of configuration that we are missing?

Thank you very much in advance.

@hkosova
Copy link
Contributor

hkosova commented Apr 19, 2019

Thanks for the report! This issue is already tracked in #5303.

@archivelm
Copy link
Author

Hi Helen,
Firstly, thank you for your prompt response, I really appreciate it.
I will join in #5303 thread, I already have some comments that might be useful.

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

No branches or pull requests

2 participants