-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from anandvarkeyphilips/development
Development of JSON validator and Formatting
- Loading branch information
Showing
17 changed files
with
2,727 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.exnihilo.validator.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.builders.RequestHandlerSelectors; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.service.Contact; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
|
||
import java.util.Collections; | ||
|
||
@Configuration | ||
public class Config { | ||
|
||
@Bean | ||
public Docket api() { | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.select() | ||
.apis(RequestHandlerSelectors.any()) | ||
.paths(PathSelectors.any()) | ||
.build().apiInfo(apiInfo()); | ||
} | ||
|
||
private ApiInfo apiInfo() { | ||
return new ApiInfo( | ||
"This REST API", | ||
"Validates yaml, json and xml files. Hi!!", | ||
"API TOS", | ||
"Terms of service", | ||
new Contact("Anand Varkey Philips", "about.me/anandvarkeyphilips", "[email protected]"), | ||
"License of API", "API license URL", Collections.emptyList()); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
src/main/java/io/exnihilo/validator/controller/EditorController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package io.exnihilo.validator.controller; | ||
|
||
import io.exnihilo.validator.entity.ValidationEntity; | ||
import io.exnihilo.validator.service.ValidatorService; | ||
import io.swagger.annotations.ApiOperation; | ||
import io.swagger.annotations.ApiResponse; | ||
import io.swagger.annotations.ApiResponses; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
@Slf4j | ||
@RestController | ||
@ApiResponses(value = { | ||
@ApiResponse(code = 200, message = "Successfully connected and validated with API Validator"), | ||
@ApiResponse(code = 401, message = "You are not authenticated properly to view the resource!"), | ||
@ApiResponse(code = 403, message = "Accessing the resource you were trying to reach is forbidden!"), | ||
@ApiResponse(code = 404, message = "Validator Service not available right now!"), | ||
}) | ||
public class EditorController { | ||
|
||
@Autowired | ||
private ValidatorService validatorService; | ||
|
||
@RequestMapping("/editor") | ||
public ModelAndView editor() { | ||
log.info("Inside editor"); | ||
return new ModelAndView("editor"); | ||
} | ||
|
||
/** | ||
* A pre-configured sample REST endpoint to demonstrate the use of Request Parameter. | ||
* | ||
* @param validationEntity | ||
* @return validation result | ||
*/ | ||
@PostMapping("/yaml") | ||
@ApiOperation( | ||
value = "API for Validating the YAML Data", | ||
notes = "This API validates YAML data input.The API is in beta phase..") | ||
public ResponseEntity<?> validateYamlController(@RequestBody ValidationEntity validationEntity) { | ||
log.debug("Calling validateYamlController..."); | ||
return new ResponseEntity<Object>(validatorService.validateYamlService(validationEntity.getValidationMessage()), HttpStatus.OK); | ||
} | ||
|
||
/** | ||
* A pre-configured sample REST endpoint to demonstrate the use of Request Parameter. | ||
* | ||
* @param validationEntity | ||
* @return validation result | ||
*/ | ||
@PostMapping("/json") | ||
@ApiOperation( | ||
value = "API for Validating the JSON Data", | ||
notes = "This API validates JSON data input.The API is in beta phase..") | ||
public ResponseEntity<?> validateJsonController(@RequestBody ValidationEntity validationEntity) { | ||
log.debug("Calling validateJsonController..."); | ||
return new ResponseEntity<Object>(validatorService.validateJsonService(validationEntity.getValidationMessage()), HttpStatus.OK); | ||
} | ||
|
||
/** | ||
* A pre-configured sample REST endpoint to demonstrate the use of Request Parameter. | ||
* | ||
* @param validationEntity | ||
* @return validation result | ||
*/ | ||
@PostMapping("/formatJson") | ||
@ApiOperation( | ||
value = "API for formatting the JSON Data", | ||
notes = "This API formats JSON data input.The API is in beta phase..") | ||
public ResponseEntity<?> formatJsonController(@RequestBody ValidationEntity validationEntity) { | ||
log.debug("Calling formatJsonController..."); | ||
return new ResponseEntity<Object>(validatorService.formatJsonService(validationEntity.getValidationMessage()), HttpStatus.OK); | ||
} | ||
} |
82 changes: 0 additions & 82 deletions
82
src/main/java/io/exnihilo/validator/controller/ValidatorController.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.