davsclaus commented on a change in pull request #435:
URL: https://github.com/apache/camel-spring-boot/pull/435#discussion_r804377056
##########
File path:
components-starter/camel-springdoc-starter/src/main/java/org/apache/camel/springboot/springdoc/SpringdocAutoConfiguration.java
##########
@@ -150,6 +166,28 @@ private OpenAPI createOpenAPI(final CamelContext
camelContext) throws Exception
.orElse(null);
}
+ /**
+ * Return the basePath for the REST services
+ * @param springContextPath the spring context path if set or empty
+ * @param basePath The apiProperty "base.path" from the REST configuration
+ * @param contextPath the REST contextPath or null.
+ * Used instead of basePath if both are non-null.
+ * @return the combined contextPath
+ */
+ private String getBasePath(String springContextPath, Object basePath,
String contextPath) {
+ if (contextPath == null) {
+ contextPath = (String)basePath; // could still be null
+ }
+ if (contextPath != null && !contextPath.isEmpty()) {
+ return springContextPath + contextPath;
+ }
+ else {
+ // This will cause problems when using the Camel servlet as the
REST component!
+ LOG.warn("No REST context path set in Camel!");
Review comment:
in Camel Rest-DSL
##########
File path:
components-starter/camel-springdoc-starter/src/main/java/org/apache/camel/springboot/springdoc/SpringdocAutoConfiguration.java
##########
@@ -124,14 +130,24 @@ private OpenAPI createOpenAPI(final CamelContext
camelContext) throws Exception
final BeanConfig bc = new BeanConfig();
final Info info = new Info();
-
final RestConfiguration rc = camelContext.getRestConfiguration();
- initOpenApi(bc, info,
Optional.ofNullable(rc.getApiProperties()).orElseGet(HashMap::new));
+ Map<String, Object> apiProps =
Optional.ofNullable(rc.getApiProperties()).orElseGet(HashMap::new);
+ initOpenApi(bc, info, apiProps,
+ getBasePath(springContextPath, apiProps.get("base.path"),
rc.getContextPath()));
final OasDocument openApi = reader.read(camelContext, rests, bc, null,
camelContext.getClassResolver());
if (!rc.isApiVendorExtension()) {
clearVendorExtensions(openApi);
}
+ // Set relative path in URL if basepath is set
+ if (bc.getBasePath()!=null && !bc.getBasePath().isEmpty() &&
openApi.is3xDocument()) {
+ for (Server server : ((Oas30Document)openApi).getServers()) {
+ if (server.url.endsWith(bc.getBasePath())) {
+ LOG.info("Setting relative URL " + bc.getBasePath());
Review comment:
Can this logging message be improved such as "Setting Server URL in
ApiDoc to base path: {}"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]