Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/swagger-gradle-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Parameter | Description | Required | Default
`ignoredRoutes`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
`objectMapperProcessorClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
`modelConverterClasses`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
`contextId`|see [Context](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#context)|false|

***

Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public enum Format {JSON, YAML, JSONANDYAML};
private LinkedHashSet<String> modelConverterClasses;
private String objectMapperProcessorClass;

private String contextId;

@Input
@Optional
public String getOutputFileName() {
Expand Down Expand Up @@ -205,6 +207,23 @@ public void setObjectMapperProcessorClass(String objectMapperProcessorClass) {
this.objectMapperProcessorClass = objectMapperProcessorClass;
}

/**
* @since 2.0.6
*/
@Input
@Optional
public String getContextId() {
return contextId;
}

/**
* @since 2.0.6
*/
public void setContextId(String contextId) {
this.contextId = contextId;
}


@Input
@Optional
public String getScannerClass() {
Expand Down Expand Up @@ -349,6 +368,11 @@ public void resolve() throws GradleException {
method.invoke(swaggerLoader, scannerClass);
}

if (StringUtils.isNotBlank(contextId)) {
method=swaggerLoaderClass.getDeclaredMethod("setContextId",String.class);
method.invoke(swaggerLoader, contextId);
}

if (StringUtils.isNotBlank(objectMapperProcessorClass)) {
method=swaggerLoaderClass.getDeclaredMethod("setObjectMapperProcessorClass",String.class);
method.invoke(swaggerLoader, objectMapperProcessorClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.swagger.v3.core.util.Json;
import io.swagger.v3.core.util.Yaml;
import io.swagger.v3.oas.integration.GenericOpenApiContextBuilder;
import io.swagger.v3.oas.integration.OpenApiConfigurationException;
import io.swagger.v3.oas.integration.SwaggerConfiguration;
import io.swagger.v3.oas.models.OpenAPI;
Expand All @@ -22,6 +23,7 @@ public class SwaggerLoader {
private String resourceClasses;
private String filterClass;
private String readerClass;
private String contextId;
private String scannerClass;
private Boolean prettyPrint = false;
private Boolean readAllResources = Boolean.TRUE;
Expand Down Expand Up @@ -92,6 +94,21 @@ public void setFilterClass(String filterClass) {
this.filterClass = filterClass;
}

/**
* @since 2.0.6
*/
public String getContextId() {
return contextId;
}

/**
* @since 2.0.6
*/
public void setContextId(String contextId) {
this.contextId = contextId;
}


public String getReaderClass() {
return readerClass;
}
Expand Down Expand Up @@ -187,8 +204,13 @@ public Map<String, String> resolve() throws Exception{
.objectMapperProcessorClass(objectMapperProcessorClass)
.modelConverterClasses(modelConverterSet);
try {
OpenAPI openAPI = new JaxrsOpenApiContextBuilder()
.openApiConfiguration(config)
GenericOpenApiContextBuilder builder = new JaxrsOpenApiContextBuilder()
.openApiConfiguration(config);
if (StringUtils.isNotBlank(contextId)) {
builder.ctxId(contextId);
}

OpenAPI openAPI = builder
.buildContext(true)
.read();
String openapiJson = null;
Expand Down
1 change: 1 addition & 0 deletions modules/swagger-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Parameter | Description | Required | Default
`ignoredRoutes`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
`objectMapperProcessorClass`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
`modelConverterClasses`|see [configuration property](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#configuration-properties)|false|
`contextId`|see [Context](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#context)|false|${project.artifactId}

***

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.swagger.v3.core.util.Json;
import io.swagger.v3.core.util.Yaml;
import io.swagger.v3.jaxrs2.integration.JaxrsOpenApiContextBuilder;
import io.swagger.v3.oas.integration.GenericOpenApiContextBuilder;
import io.swagger.v3.oas.integration.OpenApiConfigurationException;
import io.swagger.v3.oas.integration.SwaggerConfiguration;
import io.swagger.v3.oas.models.OpenAPI;
Expand Down Expand Up @@ -93,8 +94,12 @@ public void execute() throws MojoExecutionException, MojoFailureException
.objectMapperProcessorClass(objectMapperProcessorClass)
.modelConverterClasses(modelConverterClasses);
try {
OpenAPI openAPI = new JaxrsOpenApiContextBuilder()
.openApiConfiguration(config)
GenericOpenApiContextBuilder builder = new JaxrsOpenApiContextBuilder()
.openApiConfiguration(config);
if (StringUtils.isNotBlank(contextId)) {
builder.ctxId(contextId);
}
OpenAPI openAPI = builder
.buildContext(true)
.read();
String openapiJson = null;
Expand Down Expand Up @@ -163,6 +168,9 @@ public void execute() throws MojoExecutionException, MojoFailureException
private String readerClass;
@Parameter( property = "resolve.scannerClass" )
private String scannerClass;
/**
* @since 2.0.6
*/
@Parameter( property = "resolve.objectMapperProcessorClass" )
private String objectMapperProcessorClass;
@Parameter( property = "resolve.prettyPrint" )
Expand All @@ -171,6 +179,11 @@ public void execute() throws MojoExecutionException, MojoFailureException
private Boolean readAllResources = Boolean.TRUE;
@Parameter( property = "resolve.ignoredRoutes" )
private Collection<String> ignoredRoutes;
/**
* @since 2.0.6
*/
@Parameter(property = "resolve.contextId", defaultValue = "${project.artifactId}")
private String contextId;

@Parameter( property = "resolve.skip" )
private Boolean skip = Boolean.FALSE;
Expand Down