I am using swagger-codegen for generating a Java REST client for one of my REST APIs. The REST APIs take an optional header parameter. The generated methods in the client have an additional parameter that takes the header. I would like the methods to be generated without the header parameter in the method signature. I have read the documentation, but couldn't find any reference.
For example, for a GET all API with option X-CUSTOM-HEADER parameter, swagger-codegen generates a method like below:
public List<SomeType> findAllUsingGET1(String optionalHeader)
where as I would like it to be:
public List<SomeType> findAllUsingGET1()
Looking for pointers for the workaround rather than customizing the client-code generation.
EDIT 1: Adding the JSON spec
"get": {
"summary": "findAll",
"operationId": "findAllUsingGET1",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "X-CUSTOM-HEADER",
"in": "header",
"description": "Custom Header",
"required": false,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"401": {
"description": "Unauthorized"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not Found"
}
}
}
ApiClient.addDefaultHeader. The custom header is actually not optional, it is mandatory. I had to change it to optional so that I don't have to pass it in every method call. Anyways, if something is optional, then it doesn't means that we should remove it from the spec.. right? - Mubin