The ServiceLoader for JsonSchemaParserExtensions in OpenApiDeserializer is invoked for each detected schema in an OpenAPI document. The loaded Extensions should be cached statically in OpenApiDeserializer (per classloader).
We are using openapi-diff (which in turn uses the OpenAPIParser) in our apimangement application to detect api changes. The fact, that
our application has a large classpath (Spring Boot application)
the apis to be compared contain many schemas
the comparison is invoked via rest-service (embedded tomcat) - with a different context classloader, which leads to a second ServiceLoader invocation for each schema
results in poor performance (about 30 seconds) for a comparison because of multiple ServiceLoader invocations.
This is (admittedly) a special use case. But caching of all detected Extensions would be generally a good idea to avoid unnecessary classpath-scan-operations.
The ServiceLoader for
JsonSchemaParserExtension
s inOpenApiDeserializer
is invoked for each detected schema in an OpenAPI document. The loaded Extensions should be cached statically inOpenApiDeserializer
(per classloader).We are using openapi-diff (which in turn uses the
OpenAPIParser
) in our apimangement application to detect api changes. The fact, thatresults in poor performance (about 30 seconds) for a comparison because of multiple ServiceLoader invocations.
This is (admittedly) a special use case. But caching of all detected Extensions would be generally a good idea to avoid unnecessary classpath-scan-operations.
btw, there is corresponding
TODO
inSchemaProcessor
(https://github.com/swagger-api/swagger-parser/blob/master/modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/processors/SchemaProcessor.java#L49)