openapi-nexus 0.1.7

OpenAPI 3.x multi-language code generator
Documentation
// Code generated by openapi-nexus. DO NOT EDIT.
//
// Duplicate Parameter Names Test API — 1.0.0
// Test API with duplicate parameter names across different locations

package com.example.sdk.apis;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.example.sdk.models.*;
import com.example.sdk.runtime.ApiClient;
import com.example.sdk.runtime.ApiException;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import okhttp3.Request;
import okhttp3.Response;

/**
 * GetUserByIdDuplicateResponse carries the response from getUserByIdDuplicate.
 */
public class GetUserByIdDuplicateResponse {
    private final int statusCode;
    private final Response raw;
    private final GetUserByIdDuplicateResponse200 status200;

    public GetUserByIdDuplicateResponse(int statusCode, Response raw,
    GetUserByIdDuplicateResponse200 status200) {
        this.statusCode = statusCode;
        this.raw = raw;
        this.status200 = status200;
    }

    public int getStatusCode() {
        return this.statusCode;
    }

    public Response getRaw() {
        return this.raw;
    }

    public GetUserByIdDuplicateResponse200 getStatus200() {
        return this.status200;
    }
}

/**
 * UsersApi groups operations under the users tag.
 */
public class UsersApi {
    private final ApiClient client;
    private final Gson gson = new Gson();

    public UsersApi(ApiClient client) {
        this.client = client;
    }

    /**
     * Get user by ID with duplicate parameter names
     */
    public GetUserByIdDuplicateResponse getUserByIdDuplicate(long id, Long id2, String id3) throws IOException {
        String path = "/users/{id}".replace("{id}", String.valueOf(id));
        Map<String, String> query = new HashMap<>();
        if (id2 != null) {
            query.put("id", String.valueOf(id2));
        }
        Request request = client.newRequest("GET", path, query, null);
        if (id3 != null) {
            request = request.newBuilder().header("id", id3).build();
        }
        Response response = client.execute(request);

        if (!response.isSuccessful()) {
            String errorBody = response.body() != null ? response.body().string() : "";
            throw new ApiException(response.code(), response.message(), errorBody);
        }
        String responseBody = response.body() != null ? response.body().string() : "null";
        GetUserByIdDuplicateResponse200 status200 = null;
        if (response.code() == 200) {
            status200 = gson.fromJson(responseBody, new TypeToken<GetUserByIdDuplicateResponse200>() {}.getType());
        }
        return new GetUserByIdDuplicateResponse(response.code(), response, status200);
    }
}