Skip to content

Commit

Permalink
Always use base ServerModelResolver and add additional classes via co…
Browse files Browse the repository at this point in the history
…nverterClasses config property.
  • Loading branch information
noboomu committed Apr 23, 2019
1 parent 6375bfa commit 94b4dd4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ openapi {
}
]

converters = [
"io.sinistral.proteus.openapi.jaxrs2.ServerModelResolver"
converterClasses = [

]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.google.inject.name.Named;
import com.typesafe.config.Config;
import io.sinistral.proteus.openapi.jaxrs2.Reader;
import io.sinistral.proteus.openapi.jaxrs2.ServerModelResolver;
import io.sinistral.proteus.openapi.jaxrs2.ServerParameterExtension;
import io.sinistral.proteus.server.endpoints.EndpointInfo;
import io.sinistral.proteus.services.DefaultService;
Expand Down Expand Up @@ -254,7 +255,15 @@ protected void generateSpec() throws Exception

SwaggerConfiguration config = new SwaggerConfiguration().resourceClasses(classes.stream().map(Class::getName).collect(Collectors.toSet())).openAPI(openApi);

config.setModelConverterClassess(new HashSet<>( openAPIConfig.getStringList("converters") ));
Set<String> modelConverterClasses = new HashSet<>();

modelConverterClasses.add(ServerModelResolver.class.getName());

List<String> additionalConverterClasses = openAPIConfig.getStringList("converterClasses");

modelConverterClasses.addAll(additionalConverterClasses);

config.setModelConverterClassess(modelConverterClasses);

OpenApiContext ctx = new GenericOpenApiContext().openApiConfiguration(config)
.openApiReader(new Reader(config))
Expand Down
2 changes: 1 addition & 1 deletion openapi/src/test/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ application {

api.version="v1"

openapi.converters = ["io.sinistral.proteus.openapi.jaxrs2.ServerModelResolver","io.sinistral.proteus.openapi.test.converters.MoneyModelConverter"]
openapi.converterClasses = ["io.sinistral.proteus.openapi.test.converters.MoneyModelConverter"]

globalHeaders
{
Expand Down

0 comments on commit 94b4dd4

Please sign in to comment.