I use swagger-codegen
in my maven build to generate the Java interfaces for my REST layer. This works very well. However, there are a couple of parameters that I would like to exclude from the generated method's argument list.
Question
Is it possible to let swagger-codegen exclude certain parameters (e.g., by name)?
Instead of
public Response getFromEndpoint(String userToken, String xRequestId, String foo)
I would like to get
public Response getFromEndpoint(String foo)
I do want those parameters to remain in the documentation
Why
I will use the omitted headers in a filter, but subsequently they have become irrelevant in the generated method so I don't want them there.
Being able to exclude them also has the benefit that I don't have to fix every method signature in my implementation after I add a new security related parameter.
My setup
pom.xml
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.0</version>
swagger.yaml
paths:
/endpoint
get:
tags:
- example
operationId: getFromEndpoint
parameters:
- name: user-token
in: header
required: true
schema:
type: string
- name: X-request-id
in: header
required: false
schema:
type: string
- name: foo
in: header
required: true
schema:
type: string
responses:
'200':
description: sample response
content:
application/json:
schema:
type: string