@Test public void testValidJsonData() { assertTrue(jsonService.validJsonData("{ \"foo\":\"bar\" }")); assertTrue(jsonService.validJsonData("[ { \"foo\":\"bar\" }, { \"meow\":\"blah\" } ]")); assertFalse(jsonService.validJsonData(" [ { \"foo\":\"bar\" }, { \"meow\":\"blah\" } ]")); assertFalse(jsonService.validJsonData(" \"foo\":\"bar\" }, { \"meow\":\"blah\" } ]")); assertTrue(jsonService.validJsonData(jsonService.cleanJsonData(" { \"foo\":\"bar\" }"))); assertTrue(jsonService.validJsonData(jsonService.cleanJsonData("{ \"foo\":\"bar\" } "))); assertTrue(jsonService .validJsonData(jsonService.cleanJsonData(" [ { \"foo\":\"bar\" }, { \"meow\":\"blah\" } ]"))); assertTrue(jsonService.validJsonData(jsonService.cleanJsonData("\b\t\n\f\r { \"foo\":\"bar\" }"))); }
protected boolean validJsonData(String jsonData) { if (jsonData == null || jsonData.isEmpty()) { return false; } return jsonData.startsWith("{") || jsonData.startsWith("["); }
JsonService { protected boolean validJsonData(String jsonData) { if (jsonData == null || jsonData.isEmpty()) { return false; } return jsonData.startsWith("{") || jsonData.startsWith("["); } }
JsonService { protected boolean validJsonData(String jsonData) { if (jsonData == null || jsonData.isEmpty()) { return false; } return jsonData.startsWith("{") || jsonData.startsWith("["); }  }
JsonService { protected boolean validJsonData(String jsonData) { if (jsonData == null || jsonData.isEmpty()) { return false; } return jsonData.startsWith("{") || jsonData.startsWith("["); }  @GET @Path("/simple") @Produces(MediaType.TEXT_PLAIN) @Operation(summary ="Simple", description = "Simple hello service") @ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = String.class)), description = "Return a response")) String simpleHelloWorld(@Parameter(description = "From") @QueryParam("from") String from); @GET @Path("/inspect") @Produces(MediaType.APPLICATION_JSON) @Operation(summary ="Inspect JSON via URI", description = "*NOT IMPLEMENTED* Inspect a JSON schema or instance located at specified URI and return a Document object") @RequestBody(description = "Inspection type, one of `instance` or `Schema`", content = @Content(schema = @Schema(implementation = InspectionType.class))) @ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = JsonDocument.class)), description = "Return a Document object represented by JsonDocument")) Response getClass(
            @Parameter(description ="URI for JSON schema or instance") @QueryParam("uri") String uri,
            @QueryParam("type") String type); @POST @Path("/inspect") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary ="Inspect JSON", description = "Inspect a JSON schema or instance and return a Document object") @RequestBody(description = "JsonInspectionRequest object", content = @Content(schema = @Schema(implementation = JsonInspectionRequest.class))) @ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = JsonInspectionResponse.class)), description = "Return a Document object represented by JsonDocument")) Response inspectClass(InputStream requestIn); }
JsonService { protected boolean validJsonData(String jsonData) { if (jsonData == null || jsonData.isEmpty()) { return false; } return jsonData.startsWith("{") || jsonData.startsWith("["); }  @GET @Path("/simple") @Produces(MediaType.TEXT_PLAIN) @Operation(summary ="Simple", description = "Simple hello service") @ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = String.class)), description = "Return a response")) String simpleHelloWorld(@Parameter(description = "From") @QueryParam("from") String from); @GET @Path("/inspect") @Produces(MediaType.APPLICATION_JSON) @Operation(summary ="Inspect JSON via URI", description = "*NOT IMPLEMENTED* Inspect a JSON schema or instance located at specified URI and return a Document object") @RequestBody(description = "Inspection type, one of `instance` or `Schema`", content = @Content(schema = @Schema(implementation = InspectionType.class))) @ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = JsonDocument.class)), description = "Return a Document object represented by JsonDocument")) Response getClass(
            @Parameter(description ="URI for JSON schema or instance") @QueryParam("uri") String uri,
            @QueryParam("type") String type); @POST @Path("/inspect") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary ="Inspect JSON", description = "Inspect a JSON schema or instance and return a Document object") @RequestBody(description = "JsonInspectionRequest object", content = @Content(schema = @Schema(implementation = JsonInspectionRequest.class))) @ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = JsonInspectionResponse.class)), description = "Return a Document object represented by JsonDocument")) Response inspectClass(InputStream requestIn);  }