Skip to content

Commit

Permalink
Added JSON validator and Formatting capability and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
anandvarkeyphilips committed Nov 6, 2018
1 parent d1bb162 commit 36ff0bc
Show file tree
Hide file tree
Showing 14 changed files with 2,725 additions and 205 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Latest version as of 27-10-2018 is 2.0.1.RELEASE

[comment]: # (REPLACE ME: Add a Getting Started guide)

Enterprise YAML validator is better than [http://www.yamllint.com] http://www.yamllint.com
Enterprise YAML validator is better than http://www.yamllint.com.
Enterprise YAML Validator follows YAML spec, support multiple doc feature which is not supported my YAML Lint.
Also, now you dont have to use https://www.base64decode.org/,
This app also supports Decode from and to Base64 format.

Here's the working version of the Application hosted in Microsoft Azure Cloud:
[http://varkeys-rhel-jenkins.westus.cloudapp.azure.com:8090/validator/forEditor] (http://varkeys-rhel-jenkins.westus.cloudapp.azure.com:8090/validator/forEditor)
http://varkeys-rhel-jenkins.westus.cloudapp.azure.com:9090/validator/editor

![Alt text](enterprise-yaml-validator-image.PNG?raw=true "Enterprise YAML Validator")

Expand All @@ -24,14 +24,14 @@ Here's the working version of the Application hosted in Microsoft Azure Cloud:
* spring-boot-starter-freemarker
* springfox-swagger2, springfox-swagger-ui
* snakeyaml, lombok, jackson-databind, spring-boot-test
[comment]: # (REPLACE ME: Add Initial requirements like JDK version, IDE, etc)


### How to?
[comment]: # (REPLACE ME: Add your confluence page in below format)
Click on "BASE 64Encode" to encode to Base64 format.
Click on "BASE 64Encode" to decode from Base64 format.
Click on "Validate YAML" to validate YAML data.
Click on "Share YAML" to share the YAML data through Outlook Mail.
* Click on "BASE 64Encode" to encode to Base64 format.
* Click on "BASE 64Encode" to decode from Base64 format.
* Click on "Validate YAML" to validate YAML data.
* Click on "Share YAML" to share the YAML data through Outlook Mail.


### Jira
Expand Down
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,19 @@
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.23</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
public class ValidatorApplication {

public static void main(String[] args) {

SpringApplicationBuilder app = new SpringApplicationBuilder(ValidatorApplication.class);
app.build().addListeners(new ApplicationPidFileWriter());
app.run();
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/io/exnihilo/validator/config/Config.java
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());
}
}
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);
}
}

This file was deleted.

Loading

0 comments on commit 36ff0bc

Please sign in to comment.