OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.98k stars 6.6k forks source link

[BUG] [javascript] generates wrong jsdoc annnotations #19703

Open 1EDExg0ffyXfTEqdIUAYNZGnCeajIxMWd2vaQeP opened 2 months ago

1EDExg0ffyXfTEqdIUAYNZGnCeajIxMWd2vaQeP commented 2 months ago

Bug Report Checklist

Description

the generated file src/ApiClient.js contains this code:

        /**
         * The authentication methods to be included for all API calls.
         * @type {Array.<String>}
         */
        this.authentications = {
            'Bearer': {type: 'apiKey', 'in': 'header', name: 'Authorization'}
        }

Any good editor with jsdoc support will flag this as Object literal may only specify known properties, and ''Bearer'' does not exist in type 'string[]'.ts(2353), because the jsdoc says its an array of string, but it's assigned a map from string to objects.

A similar error occurs for defaultHeaders.

The jsdoc for callApi refers toa type ObjectFunction, which is not defined.

openapi-generator version

7.8.0

OpenAPI declaration file content or url

I don;t think it's relevant

Generation Details

using npm openapi-generator-cli generate -i ./openapi.json -g javascript -o ./generated

1EDExg0ffyXfTEqdIUAYNZGnCeajIxMWd2vaQeP commented 1 month ago

This jsdoc is also wrong, the parameter names should be opts.page and opts.limit respectively:

current

    /**
     * Get all Customers
     * Get all Customers
     * @param {Object} opts Optional parameters
     * @param {Number} [page] Page you want to display   // THIS LINE IS WRONG
     * @param {Number} [limit] Items per page            // THIS LINE IS WRONG
     * @param {module:api/CustomerApi~customersGetCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link Array.<module:model/CustomersGet200ResponseInner>}
     */
    customersGet(opts, callback) {
      opts = opts || {};
      let postBody = null;

      let pathParams = {
      };
      let queryParams = {
        'page': opts['page'],
        'limit': opts['limit']
      };