swaggest / swac

🤖 OpenAPI/Swagger client generator for PHP, Go and JavaScript (ES5)
MIT License
9 stars 3 forks source link

getResponse() switch without case #31

Closed BirknerAlex closed 3 years ago

BirknerAlex commented 3 years ago

Hey,

I've been trying to use swac to generate an API client for Netbox. The OpenAPI documentation can be found under https://netboxdemo.com/api/docs/?format=openapi.

A generated getResponse() method looks like this:

    /**
     * @return mixed
     * @throws RestException
     * @throws InvalidValue
     * @throws Exception
     * @throws GuzzleException
     */
    public function getResponse()
    {
        $raw = $this->getRawResponse();
        $statusCode = $raw->getStatusCode();
        switch ($statusCode) {
            default: throw new RestException('Unsupported response status code: ' . $statusCode, RestException::UNSUPPORTED_RESPONSE_CODE);
        }
        return $result;
    }

It seems the switch case for status code 200 is missing but the OpenAPI response does contain a status 200 in the json. So every successful call does throw the Unsupported response status code Exception.

vearutop commented 3 years ago

@BirknerAlex please try v0.1.26.

BirknerAlex commented 3 years ago

Looks good, thanks for the fast fix!