Swagger-codegen: [JAVA] Using API Key in Swagger with JAVA

Created on 1 Dec 2017  路  7Comments  路  Source: swagger-api/swagger-codegen

Description

I have created a YAML file with the Swagger Editor (Local). I used API keys as security. I then downloaded the server source code via the Swagger Editor. in the Java codes, the API-KEY does not appear, if I test the server I can use the calls without API-KEY, even though this is defined differently in the YAML file. Am I doing something wrong, is my approach wrong or is this an error generating the source code?

Swagger-codegen version

Swagger Editor
Version 2.10.3

Swagger declaration file content or url
Command line used for generation

no command line i use the editor

Steps to reproduce

N/A
swagger (4).yaml.zip

Suggestion help wanted

Most helpful comment

@MultiStorm are you using OAuth2 or which kind of key/ token? I'm willing to create a PR to use CXFs BearerAuthSupplier/ CodeAuthSupplier (see http://cxf.apache.org/docs/jax-rs-oauth2.html) but first I'd like to understand your use case.

Btw could you please update the title of this issue with a more specific one?

All 7 comments

Which generator are you referring to?

I refer to the generator supplied with the Swagger Editor. I have no extra generator installed. I downloaded the Swagger Editor from your website and put it into my Apache server. in the editor I can say above in the Generate Server Code menu. Dan I get as a download a zip file with a Maven project.

@MultiStorm there are many different server generators listed under the "Generate Server Code" menu such as Java Spring, JAX-RS, etc

Which one did you use?

oh sorry Jaxrs Cfx :-)

If it helps, can you watch the whole thing via Teamviewer?

Looks like JAX-RS CXF does not leverage {{authMethods}} at the moment:

$ grep -R -i authMethod modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/*
$ 

Would you have time to contribute the enhancement?

@MultiStorm are you using OAuth2 or which kind of key/ token? I'm willing to create a PR to use CXFs BearerAuthSupplier/ CodeAuthSupplier (see http://cxf.apache.org/docs/jax-rs-oauth2.html) but first I'd like to understand your use case.

Btw could you please update the title of this issue with a more specific one?

Was this page helpful?
0 / 5 - 0 ratings