swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

don't add body params from spec

Open AlexProfi opened this issue 3 years ago • 0 comments

Q&A (please complete the following information)

  • OS: linux ubuntu
  • Browser: firefox 103
  • Version: swagger-codegen-cli-3.0.34.jar
  • Method of installation: dist assets
  • Swagger-UI version: 3.0.34
  • Swagger/OpenAPI version: openapi: 3.0.1

Content & configuration

Example Swagger/OpenAPI definition:

/dict/{slug}/{code}:
    patch:
      tags:
      - dict
      summary: Обновляет данные справочника
      description: Обновляет данные справочника
      operationId: dict-patch
      consumes:
        - application/json
      parameters:
      - name: slug
        in: path
        description: 'Символьная метка справочника (например: institution)'
        required: true
        schema:
          type: string
      - name: code
        in: path
        description: 'Идентификатор эл-та справочника (например: 767890)'
        required: true
        schema:
          type: string
      - name: data
        in: body

        description: The dict to create.
        schema:
          type: object
          required:
            - name
          properties:
            name:
              type: string
            short_name:
              type: string
            mr_id:
              type: string
            fias:
              type: string
            number:
              type: number

      responses:
        200:
          description: Успешная операция
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DictResult'
        404:
          description: Справочник указанного типа не найден
          content: {}
      security:
      - basic: []

Swagger-UI configuration options:

SwaggerUI({
  java -jar swagger-codegen-cli.jar generate -i swagger-codegen-cli.jar -i static/openapi/schema_3.yaml --git-user-id "Alex" \
 --git-repo-id "swagger_client" -s False -c config.json -l python -o rsmev_swagger_clien
})

Describe the bug you're encountering

To reproduce...

Steps to reproduce the behavior:

  1. generate api with this yaml ( get from help)'

  2. open result code

  3. Scroll down to dict_patch method

  4. and see

  5. ` def dict_patch(self, slug, code, **kwargs): # noqa: E501 """Обновляет данные справочника # noqa: E501

     Обновляет данные справочника  # noqa: E501
     This method makes a synchronous HTTP request by default. To make an
     asynchronous HTTP request, please pass async_req=True
     >>> thread = api.dict_patch(slug, code, async_req=True)
     >>> result = thread.get()
    
     :param async_req bool
     :param str slug: Символьная метка справочника (например: institution) (required)
     :param str code: Идентификатор эл-та справочника (например: 767890) (required)
     :return: DictResult
              If the method is called asynchronously,
              returns the request thread.
     """
     kwargs['_return_http_data_only'] = True
     if kwargs.get('async_req'):
         return self.dict_patch_with_http_info(slug, code, **kwargs)  # noqa: E501
     else:
         (data) = self.dict_patch_with_http_info(slug, code, **kwargs)  # noqa: E501
         return data
    

    def dict_patch_with_http_info(self, slug, code, **kwargs): # noqa: E501 """Обновляет данные справочника # noqa: E501

     Обновляет данные справочника  # noqa: E501
     This method makes a synchronous HTTP request by default. To make an
     asynchronous HTTP request, please pass async_req=True
     >>> thread = api.dict_patch_with_http_info(slug, code, async_req=True)
     >>> result = thread.get()
    
     :param async_req bool
     :param str slug: Символьная метка справочника (например: institution) (required)
     :param str code: Идентификатор эл-та справочника (например: 767890) (required)
     :return: DictResult
              If the method is called asynchronously,
              returns the request thread.
     """
    
     all_params = ['slug', 'code']  # noqa: E501
     all_params.append('async_req')
     all_params.append('_return_http_data_only')
     all_params.append('_preload_content')
     all_params.append('_request_timeout')
    
     params = locals()
     for key, val in six.iteritems(params['kwargs']):
         if key not in all_params:
             raise TypeError(
                 "Got an unexpected keyword argument '%s'"
                 " to method dict_patch" % key
             )
         params[key] = val
     del params['kwargs']
     # verify the required parameter 'slug' is set
     if ('slug' not in params or
             params['slug'] is None):
         raise ValueError("Missing the required parameter `slug` when calling `dict_patch`")  # noqa: E501
     # verify the required parameter 'code' is set
     if ('code' not in params or
             params['code'] is None):
         raise ValueError("Missing the required parameter `code` when calling `dict_patch`")  # noqa: E501
    
     collection_formats = {}
    
     path_params = {}
     if 'slug' in params:
         path_params['slug'] = params['slug']  # noqa: E501
     if 'code' in params:
         path_params['code'] = params['code']  # noqa: E501
    
     query_params = []
    
     header_params = {}
    
     form_params = []
     local_var_files = {}
    
     body_params = None
     # HTTP header `Accept`
     header_params['Accept'] = self.api_client.select_header_accept(
         ['application/json'])  # noqa: E501
    
     # Authentication setting
     auth_settings = ['basic']  # noqa: E501
    
     return self.api_client.call_api(
         '/dict/{slug}/{code}', 'PATCH',
         path_params,
         query_params,
         header_params,
         body=body_params,
         post_params=form_params,
         files=local_var_files,
         response_type='DictResult',  # noqa: E501
         auth_settings=auth_settings,
         async_req=params.get('async_req'),
         _return_http_data_only=params.get('_return_http_data_only'),
         _preload_content=params.get('_preload_content', True),
         _request_timeout=params.get('_request_timeout'),
         collection_formats=collection_formats)`
    

there is now proccessing body params

Expected behavior

i want to add data to body params from data parameter

AlexProfi avatar Aug 14 '22 21:08 AlexProfi