File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
modules/swagger-codegen-cli/src/main/java/com/wordnik/swagger/codegen/cmd Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 1
1
package com .wordnik .swagger .codegen .cmd ;
2
2
3
+ import com .fasterxml .jackson .dataformat .yaml .snakeyaml .external .biz .base64Coder .Base64Coder ;
3
4
import com .wordnik .swagger .codegen .ClientOptInput ;
4
5
import com .wordnik .swagger .codegen .ClientOpts ;
5
6
import com .wordnik .swagger .codegen .CodegenConfig ;
@@ -54,6 +55,11 @@ public class Generate implements Runnable {
54
55
"Pass in a URL-encoded string of name:header with a comma separating multiple values" )
55
56
private String auth ;
56
57
58
+ @ Option (name = {"-b" , "--basic-auth" }, title = "basic auth" ,
59
+ description = "adds basic auth headers when fetching swagger defenitions remotly and server is user basic auth to authenticate. " +
60
+ "Pass in arguments in the following format <username>:<password>" )
61
+ private String basicAuth ;
62
+
57
63
@ Override
58
64
public void run () {
59
65
verbosed (verbose );
@@ -64,6 +70,11 @@ public void run() {
64
70
input .setAuth (auth );
65
71
}
66
72
73
+ if (isNotEmpty (basicAuth )) {
74
+ String authorization = new String (Base64Coder .encode (basicAuth .getBytes ()));
75
+ input .setAuth ("Authorization:" + "Basic " + authorization );
76
+ }
77
+
67
78
CodegenConfig config = forName (lang );
68
79
config .setOutputDir (new File (output ).getAbsolutePath ());
69
80
You can’t perform that action at this time.
0 commit comments