mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 06:00:52 +00:00
fix, tests for #2500
This commit is contained in:
parent
a1c978751a
commit
3ea911dd74
@ -2,6 +2,7 @@ package io.swagger.generator.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.models.auth.AuthorizationValue;
|
||||
import io.swagger.models.auth.SecuritySchemeDefinition;
|
||||
|
||||
import java.util.Map;
|
||||
@ -11,6 +12,15 @@ public class GeneratorInput {
|
||||
private Map<String, String> options;
|
||||
private String swaggerUrl;
|
||||
private SecuritySchemeDefinition auth;
|
||||
private AuthorizationValue authorizationValue;
|
||||
|
||||
public AuthorizationValue getAuthorizationValue() {
|
||||
return authorizationValue;
|
||||
}
|
||||
|
||||
public void setAuthorizationValue(AuthorizationValue authorizationValue) {
|
||||
this.authorizationValue = authorizationValue;
|
||||
}
|
||||
|
||||
@ApiModelProperty(dataType = "Object")
|
||||
public JsonNode getSpec() {
|
||||
@ -38,10 +48,12 @@ public class GeneratorInput {
|
||||
this.swaggerUrl = url;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public SecuritySchemeDefinition getSecurityDefinition() {
|
||||
return auth;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setSecurityDefinition(SecuritySchemeDefinition auth) {
|
||||
this.auth = auth;
|
||||
}
|
||||
|
@ -1,22 +1,16 @@
|
||||
package io.swagger.generator.online;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import io.swagger.codegen.CliOption;
|
||||
import io.swagger.codegen.ClientOptInput;
|
||||
import io.swagger.codegen.ClientOpts;
|
||||
import io.swagger.codegen.Codegen;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.CodegenConfigLoader;
|
||||
import io.swagger.codegen.*;
|
||||
import io.swagger.generator.exception.ApiException;
|
||||
import io.swagger.generator.exception.BadRequestException;
|
||||
import io.swagger.generator.model.GeneratorInput;
|
||||
import io.swagger.generator.model.InputOption;
|
||||
import io.swagger.generator.util.ZipUtil;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.models.auth.AuthorizationValue;
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
import io.swagger.util.Json;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -79,11 +73,24 @@ public class Generator {
|
||||
Swagger swagger;
|
||||
if (node == null) {
|
||||
if (opts.getSwaggerUrl() != null) {
|
||||
swagger = new SwaggerParser().read(opts.getSwaggerUrl());
|
||||
if(opts.getAuthorizationValue() != null) {
|
||||
List<AuthorizationValue> authorizationValues = new ArrayList<AuthorizationValue>();
|
||||
authorizationValues.add(opts.getAuthorizationValue());
|
||||
|
||||
swagger = new SwaggerParser().read(opts.getSwaggerUrl(), authorizationValues, true);
|
||||
}
|
||||
else {
|
||||
swagger = new SwaggerParser().read(opts.getSwaggerUrl());
|
||||
}
|
||||
} else {
|
||||
throw new BadRequestException("No swagger specification was supplied");
|
||||
}
|
||||
} else {
|
||||
} else if(opts.getAuthorizationValue() != null) {
|
||||
List<AuthorizationValue> authorizationValues = new ArrayList<AuthorizationValue>();
|
||||
authorizationValues.add(opts.getAuthorizationValue());
|
||||
swagger = new SwaggerParser().read(node, authorizationValues, true);
|
||||
}
|
||||
else {
|
||||
swagger = new SwaggerParser().read(node, true);
|
||||
}
|
||||
if (swagger == null) {
|
||||
|
2
pom.xml
2
pom.xml
@ -559,7 +559,7 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<swagger-parser-version>1.0.18</swagger-parser-version>
|
||||
<swagger-parser-version>1.0.19-SNAPSHOT</swagger-parser-version>
|
||||
<scala-version>2.11.1</scala-version>
|
||||
<felix-version>2.3.4</felix-version>
|
||||
<swagger-core-version>1.5.8</swagger-core-version>
|
||||
|
Loading…
x
Reference in New Issue
Block a user