diff --git a/README.md b/README.md index b15b44c..d2ee578 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,12 @@ Example POST request: https://api.dev.smartclide.eu/architectural-patterns/appli ### Response -Content-Type: `text/plain` +The template repository URL on GitHub, e.g., `https://github.com/che-samples/web-java-spring-boot` -A repository URL on GitHub, e.g., `https://github.com/che-samples/web-java-spring-boot` +Content-Type: `application/json` +```json +{ + "templateRepositoryUrl": "https://github.com/che-samples/web-java-spring-boot" +} +``` diff --git a/src/main/java/org/eclipse/opensmartclide/architecturalpatterns/application/PatternApplicationController.java b/src/main/java/org/eclipse/opensmartclide/architecturalpatterns/application/PatternApplicationController.java index afdee1c..18dd021 100644 --- a/src/main/java/org/eclipse/opensmartclide/architecturalpatterns/application/PatternApplicationController.java +++ b/src/main/java/org/eclipse/opensmartclide/architecturalpatterns/application/PatternApplicationController.java @@ -5,11 +5,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ResponseStatusException; +import java.util.Map; @RestController public class PatternApplicationController { @@ -21,15 +23,15 @@ public PatternApplicationController(final ArchitecturalPatternsJsonHandler jsonH this.projectJsonHandler = jsonHandler; } - @PostMapping(value = "/application") - public String applyPattern(@RequestParam("framework") String framework, - @RequestParam("pattern") String pattern) { + @PostMapping(value = "/application", produces = MediaType.APPLICATION_JSON_VALUE) + public Map applyPattern(@RequestParam("framework") String framework, + @RequestParam("pattern") String pattern) { try { String repoUrl = getProjectURL(framework, pattern); if (repoUrl == null) { throw new NullPointerException("Repository URL is not found."); } - return repoUrl; + return Map.of("templateRepositoryUrl", repoUrl); } catch (Exception e) { logger.error("Exception during pattern application.", e); throw new ResponseStatusException(