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

Swagger Codegen version: 3.0.65 broke my javascript client code #1330

Closed
ralpheichelberger opened this issue Dec 18, 2024 · 1 comment
Closed

Comments

@ralpheichelberger
Copy link

ralpheichelberger commented Dec 18, 2024

image

my YAML didn't change
but now every returnType is set to null

I looked at what has changed, but I only found that there was a change vom cli version 43 to 44 and there some java framework changed.

The error occurs if you don't use inline responses but create a response under components / responses like this:

openapi: 3.0.1
info:
  title: Simple API
  version: 1.0.0
  description: Eine einfache API mit einem Array von Objekten als Rückgabewert.

paths:
  /items:
    get:
      summary: Hole ein Array von Objekten
      description: Gibt eine Liste von Objekten zurück.
      responses:
        '200':
          $ref: '#/components/responses/ItemListResponse'

components:
  schemas:
    Item:
      type: object
      properties:
        id:
          type: integer
          example: 1
        name:
          type: string
          example: "Testobjekt"
        price:
          type: number
          format: float
          example: 19.99

  responses:
    ItemListResponse:
      description: Erfolgreiche Antwort mit einer Liste von Objekten.
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: '#/components/schemas/Item'

Then the resulting DefaultApi.js looks like this:

/*
 * Simple API
 * Eine einfache API mit einem Array von Objekten als Rückgabewert.
 *
 * OpenAPI spec version: 1.0.0
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 *
 * Swagger Codegen version: 3.0.65
 *
 * Do not edit the class manually.
 *
 */
import ApiClient from "../ApiClient";

/**
* Default service.
* @module api/DefaultApi
* @version 1.0.0
*/
export default class DefaultApi {

    /**
    * Constructs a new DefaultApi. 
    * @alias module:api/DefaultApi
    * @class
    * @param {module:ApiClient} [apiClient] Optional API client implementation to use,
    * default to {@link module:ApiClient#instanc
    e} if unspecified.
    */
    constructor(apiClient) {
        this.apiClient = apiClient || ApiClient.instance;
    }

    /**
     * Callback function to receive the result of the itemsGet operation.
     * @callback moduleapi/DefaultApi~itemsGetCallback
     * @param {String} error Error message, if any.
     * @param data This operation does not return a value.
     * @param {String} response The complete HTTP response.
     */

    /**
     * Hole ein Array von Objekten
     * Gibt eine Liste von Objekten zurück.
     * @param {module:api/DefaultApi~itemsGetCallback} callback The callback function, accepting three arguments: error, data, response
     */
    itemsGet(callback) {
      
      let postBody = null;

      let pathParams = {
        
      };
      let queryParams = {
        
      };
      let headerParams = {
        
      };
      let formParams = {
        
      };

      let authNames = [];
      let contentTypes = [];
      let accepts = [];
      let returnType = null;

      return this.apiClient.callApi(
        '/items', 'GET',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, callback
      );
    }

}

And this won't give you the result of the server back.

@frantuma
Copy link
Member

fixed in swagger-api/swagger-codegen#12507

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