io.swagger.v3.oas.annotations.responses.ApiResponse Java Examples

The following examples show how to use io.swagger.v3.oas.annotations.responses.ApiResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SetsResource.java    From cantor with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
@DELETE
@Path("/{namespace}/{set}/{entry}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Delete a specific entry by name")
@ApiResponses(value = {
    @ApiResponse(responseCode = "200",
                 description = "Provides single property json with a boolean which is only true if the key was found and the entry was deleted",
                 content = @Content(schema = @Schema(implementation = HttpModels.DeleteResponse.class))),
    @ApiResponse(responseCode = "500", description = serverErrorMessage)
})
public Response delete(@Parameter(description = "Namespace identifier") @PathParam("namespace") final String namespace,
                       @Parameter(description = "Name of the set") @PathParam("set") final String set,
                       @Parameter(description = "Name of the entry") @PathParam("entry") final String entry) throws IOException {
    logger.info("received request to delete entry {} in set/namespace {}/{}", entry, set, namespace);
    final Map<String, Boolean> completed = new HashMap<>();
    completed.put(jsonFieldResults, this.cantor.sets().delete(namespace, set, entry));
    return Response.ok(parser.toJson(completed)).build();
}
 
Example #2
Source File: QuoteRouter.java    From springdoc-openapi with Apache License 2.0 6 votes vote down vote up
@RouterOperations({
		@RouterOperation(path = "/hello", operation = @Operation(operationId = "hello", responses = @ApiResponse(responseCode = "200"))),
		@RouterOperation(path = "/echo", produces = TEXT_PLAIN_VALUE, operation = @Operation(operationId = "echo", requestBody = @RequestBody(content = @Content(schema = @Schema(type = "string"))),
				responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "string"))))),
		@RouterOperation(path = "/echo",produces = APPLICATION_JSON_VALUE,  operation = @Operation(operationId = "echo", requestBody = @RequestBody(content = @Content(schema = @Schema(type = "string"))),
				responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "string"))))),
		@RouterOperation(path = "/quotes", produces = APPLICATION_JSON_VALUE, operation = @Operation(operationId = "fetchQuotes", parameters = @Parameter(name = "size", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
				responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Quote.class)))))),
		@RouterOperation(path = "/quotes", produces = APPLICATION_STREAM_JSON_VALUE, operation = @Operation(operationId = "fetchQuotes",
				responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Quote.class))))) })
@Bean
public RouterFunction<ServerResponse> route(QuoteHandler quoteHandler) {
	return RouterFunctions
			.route(GET("/hello").and(accept(TEXT_PLAIN)), quoteHandler::hello)
			.andRoute(POST("/echo").and(accept(TEXT_PLAIN).and(contentType(TEXT_PLAIN))), quoteHandler::echo)
			.andRoute(POST("/echo").and(accept(APPLICATION_JSON).and(contentType(APPLICATION_JSON))), quoteHandler::echo)
			.andRoute(GET("/quotes").and(accept(APPLICATION_JSON)), quoteHandler::fetchQuotes)
			.andRoute(GET("/quotes").and(accept(APPLICATION_STREAM_JSON)), quoteHandler::streamQuotes);
}
 
Example #3
Source File: PositionRouter.java    From springdoc-openapi with Apache License 2.0 6 votes vote down vote up
@Bean
@RouterOperations({ @RouterOperation(path = "/getAllPositions", operation = @Operation(description = "Get all positions", operationId = "findAll",tags = "positions",
		responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Position.class)))))),
		@RouterOperation(path = "/getPosition/{id}", operation = @Operation(description = "Find all", operationId = "findById", tags = "positions",parameters = @Parameter(name = "id", in = ParameterIn.PATH),
				 responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Position.class))))),
		@RouterOperation(path = "/createPosition",  operation = @Operation(description = "Save position", operationId = "save", tags = "positions",requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = Position.class))),
				responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Position.class))))),
		@RouterOperation(path = "/deletePosition/{id}", operation = @Operation(description = "Delete By Id", operationId = "deleteBy",tags = "positions", parameters = @Parameter(name = "id", in = ParameterIn.PATH),
				responses = @ApiResponse(responseCode = "200", content = @Content)))})
public RouterFunction<ServerResponse> positionRoute(PositionHandler handler) {
	return RouterFunctions
			.route(GET("/getAllPositions").and(accept(MediaType.APPLICATION_JSON)), handler::findAll)
			.andRoute(GET("/getPosition/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById)
			.andRoute(POST("/createPosition").and(accept(MediaType.APPLICATION_JSON)), handler::save)
			.andRoute(DELETE("/deletePosition/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete);
}
 
Example #4
Source File: SetsResource.java    From cantor with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@GET
@Path("/{namespace}/{set}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Get entries from a set")
@ApiResponses(value = {
    @ApiResponse(responseCode = "200",
                 description = "Provides entry names and weights matching query parameters as properties in a json",
                 content = @Content(schema = @Schema(implementation = Map.class))),
    @ApiResponse(responseCode = "400", description = "One of the query parameters has a bad value"),
    @ApiResponse(responseCode = "500", description = serverErrorMessage)
})
public Response get(@Parameter(description = "Namespace identifier") @PathParam("namespace") final String namespace,
                    @Parameter(description = "Name of the set") @PathParam("set") final String set,
                    @BeanParam final SetsDataSourceBean bean) throws IOException {
    logger.info("received request for values in set/namespace {}/{}", set, namespace);
    logger.debug("request parameters: {}", bean);
    final Map<String, Long> entries = this.cantor.sets().get(
            namespace,
            set,
            bean.getMin(),
            bean.getMax(),
            bean.getStart(),
            bean.getCount(),
            bean.isAscending());
    return Response.ok(parser.toJson(entries)).build();
}
 
Example #5
Source File: HelloController.java    From springdoc-openapi with Apache License 2.0 6 votes vote down vote up
@PostMapping("/test1")
@Operation(summary = "Example api that realize an ECHO operation",
		description = "The result of the echo is the input value of the api",
		parameters = { @Parameter(in = ParameterIn.PATH,
				name = "uuid",
				required = true,
				description = "Is the identification of the document",
				schema = @Schema(type = "string",
						example = "uuid")) }


)
@ApiResponses(value = {
		@ApiResponse(description = "Successful Operation",
				responseCode = "200",
				content = @Content(mediaType = "application/json",
						schema = @Schema(implementation = PersonDTO.class))),
		@ApiResponse(responseCode = "201",
				description = "other possible response")
})
public String postMyRequestBody1() {
	return null;
}
 
Example #6
Source File: HelloController.java    From springdoc-openapi with Apache License 2.0 6 votes vote down vote up
@PostMapping("/test3")
@Operation(summary = "Example api that realize an ECHO operation",
		description = "The result of the echo is the input value of the api",
		parameters = { @Parameter(in = ParameterIn.PATH,
				name = "uuid",
				required = true,
				description = "Is the identification of the document",
				schema = @Schema(type = "string",
						example = "uuid")) }


)
@ApiResponse(responseCode = "201",
		description = "other possible response")
public String postMyRequestBody3() {
	return null;
}
 
Example #7
Source File: ObjectsResource.java    From cantor with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@GET
@Path("/size/{namespace}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "View size of a namespace")
@ApiResponses(value = {
    @ApiResponse(responseCode = "200",
                 description = "Provides single property json with the number of objects in a namespace",
                 content = @Content(schema = @Schema(implementation = HttpModels.SizeResponse.class))),
    @ApiResponse(responseCode = "500", description = serverErrorMessage)
})
public Response size(@Parameter(description = "Namespace identifier") @PathParam("namespace") final String namespace) throws IOException {
    logger.info("received request to get size of namespace {}", namespace);
    final Map<String, Integer> completed = new HashMap<>();
    completed.put(jsonFieldSize, this.cantor.objects().size(namespace));
    return Response.ok(parser.toJson(completed)).build();
}
 
Example #8
Source File: OperationMethodAnnotationProcessor.java    From servicecomb-toolkit with Apache License 2.0 6 votes vote down vote up
@Override
public void process(Operation annotation, OperationContext context) {

  context.setOperationId(annotation.operationId());
  context.setDeprecated(annotation.deprecated());
  context.setDescription(annotation.description());

  Map<String, Object> extensionsFromAnnotation = SwaggerAnnotationUtils
      .getExtensionsFromAnnotation(annotation.extensions());
  Optional.ofNullable(extensionsFromAnnotation)
      .ifPresent(extensions -> extensions.forEach(context::addExtension));

  ApiResponse[] responses = annotation.responses();
  MethodAnnotationProcessor apiResponseAnnotationProcessor = context.getParser()
      .findMethodAnnotationProcessor(ApiResponse.class);

  for (ApiResponse response : responses) {
    Optional.ofNullable(apiResponseAnnotationProcessor)
        .ifPresent(processor -> processor.process(response, context));
  }

  context.setHttpMethod(annotation.method());
  context.setSummary(annotation.summary());
  Arrays.stream(annotation.tags()).forEach(context::addTag);
}
 
Example #9
Source File: ExperimentRestApi.java    From submarine with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/logs/{id}")
@Operation(summary = "Log experiment by id",
        tags = {"experiment"},
        responses = {
                @ApiResponse(description = "successful operation", content = @Content(
                        schema = @Schema(implementation = JsonResponse.class))),
                @ApiResponse(responseCode = "404", description = "Experiment not found")})
public Response getLog(@PathParam(RestConstants.ID) String id) {
  try {
    ExperimentLog experimentLog = experimentManager.getExperimentLog(id);
    return new JsonResponse.Builder<ExperimentLog>(Response.Status.OK).success(true)
        .result(experimentLog).build();

  } catch (SubmarineRuntimeException e) {
    return parseExperimentServiceException(e);
  }
}
 
Example #10
Source File: SetsResource.java    From cantor with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@GET
@Path("/intersect/{namespace}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Perform an intersection of all provided sets")
@ApiResponses(value = {
    @ApiResponse(responseCode = "200",
                 description = "Provides an intersection of all entries filtered by query parameters as properties in a json",
                 content = @Content(schema = @Schema(implementation = Map.class))),
    @ApiResponse(responseCode = "400", description = "One of the query parameters has a bad value"),
    @ApiResponse(responseCode = "500", description = serverErrorMessage)
})
public Response intersect(@Parameter(description = "Namespace identifier") @PathParam("namespace") final String namespace,
                          @Parameter(description = "List of sets") @QueryParam("set") final List<String> sets,
                          @BeanParam final SetsDataSourceBean bean) throws IOException {
    logger.info("received request for intersection of sets {} in namespace {}", sets, namespace);
    logger.debug("request parameters: {}", bean);
    final Map<String, Long> intersection = this.cantor.sets().intersect(
            namespace,
            sets,
            bean.getMin(),
            bean.getMax(),
            bean.getStart(),
            bean.getCount(),
            bean.isAscending());
    return Response.ok(parser.toJson(intersection)).build();
}
 
Example #11
Source File: ExperimentRestApi.java    From submarine with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the experiment that deleted
 * @param id experiment id
 * @return the detailed info about deleted experiment
 */
@DELETE
@Path("/{id}")
@Operation(summary = "Delete the experiment",
        tags = {"experiment"},
        responses = {
                @ApiResponse(description = "successful operation", content = @Content(
                        schema = @Schema(implementation = JsonResponse.class))),
                @ApiResponse(responseCode = "404", description = "Experiment not found")})
public Response deleteExperiment(@PathParam(RestConstants.ID) String id) {
  try {
    Experiment experiment = experimentManager.deleteExperiment(id);
    return new JsonResponse.Builder<Experiment>(Response.Status.OK).success(true)
        .result(experiment).build();
  } catch (SubmarineRuntimeException e) {
    return parseExperimentServiceException(e);
  }
}
 
Example #12
Source File: FunctionsResource.java    From cantor with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@DELETE
@Path("/run/{namespace}/{function}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Execute delete method on function query")
@ApiResponses(value = {
        @ApiResponse(responseCode = "200",
                description = "Process and execute the function",
                content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))),
        @ApiResponse(responseCode = "500", description = serverErrorMessage)
})
public Response deleteExecuteFunction(@PathParam("namespace") final String namespace,
                                      @PathParam("function") final String function,
                                      @Context final HttpServletRequest request,
                                      @Context final HttpServletResponse response) {
    logger.info("executing '{}/{}' with delete method", namespace, function);
    return doExecute(namespace, function, request, response);
}
 
Example #13
Source File: ObjectsResource.java    From cantor with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@DELETE
@Path("/{namespace}/{key}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Delete an object by its key")
@ApiResponses(value = {
    @ApiResponse(responseCode = "200",
                 description = "Provides single property json with a boolean which is only true if the key was found and the object was deleted",
                 content = @Content(schema = @Schema(implementation = HttpModels.DeleteResponse.class))),
    @ApiResponse(responseCode = "500", description = serverErrorMessage)
})
public Response deleteByKey(@Parameter(description = "Namespace identifier") @PathParam("namespace") final String namespace,
                            @Parameter(description = "Key of the object") @PathParam("key") final String key) throws IOException {
    logger.info("received request to delete object '{}' in namespace {}", key, namespace);
    final Map<String, Boolean> completed = new HashMap<>();
    completed.put(jsonFieldResults, this.cantor.objects().delete(namespace, key));
    return Response.ok(parser.toJson(completed)).build();
}
 
Example #14
Source File: HelloController.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@GetMapping
@ApiResponses({
		@ApiResponse(responseCode = "202", description = "${test.app99.operation.persons.response.202.description}")
})
public void persons() {

}
 
Example #15
Source File: HelloController.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@PostMapping(value = "/helloworld", produces = "application/json", consumes = "application/vnd.v2+json")
@ApiResponses({
		@ApiResponse(responseCode = "200", description = "Successful operation", content = @Content(schema = @Schema(implementation = HelloDTO2.class))),
		@ApiResponse(responseCode = "400", description = "Bad name", content = @Content(schema = @Schema(implementation = ErrorDTO.class))) })
public ResponseEntity<?> hello(@RequestBody RequestV2 request) {
	final String name = request.getNameV2();
	if ("error".equalsIgnoreCase(name)) {
		return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ErrorDTO("invalid name: " + name));
	}
	return ResponseEntity.ok(new HelloDTO2("Greetings from Spring Boot v2! " + name));
}
 
Example #16
Source File: MostRecentEntryProxyResource.java    From browserup-proxy with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/assertStatusInformational")
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "In case url pattern is provided assert that the most recent response " +
        "found by url pattern has status belonging to INFORMATIONAL class (1xx), otherwise " +
        "assert that the most recent response has status belonging to INFORMATIONAL class (1xx).",
        responses = {@ApiResponse(
                description = "Assertion result",
                content = @Content(
                        mediaType = MediaType.APPLICATION_JSON,
                        schema = @Schema(implementation = AssertionResult.class)))})
public AssertionResult statusInformational(
        @PathParam(PORT)
        @NotNullConstraint(paramName = PORT)
        @PortWithExistingProxyConstraint
        @Parameter(required = true, in = ParameterIn.PATH, description = PORT_DESCRIPTION) int port,

        @QueryParam(URL_PATTERN)
        @NotBlankConstraint(paramName = URL_PATTERN)
        @PatternConstraint(paramName = URL_PATTERN)
        @Parameter(description = URL_PATTERN_DESCRIPTION) String urlPattern) {

    MitmProxyServer proxyServer = proxyManager.get(port);

    return urlPattern.isEmpty() ?
            proxyServer.assertMostRecentResponseStatusCode(HttpStatusClass.INFORMATIONAL) :
            proxyServer.assertMostRecentResponseStatusCode(Pattern.compile(urlPattern), HttpStatusClass.INFORMATIONAL);
}
 
Example #17
Source File: InventoryApi.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(description = "adds an inventory item", operationId = "addInventory", summary = "Adds an item to the system", tags = {
		"admins", })
@ApiResponses(value = { @ApiResponse(responseCode = "201", description = "item created"),
		@ApiResponse(responseCode = "400", description = "invalid input, object invalid"),
		@ApiResponse(responseCode = "409", description = "an existing item already exists") })
@PostMapping(value = "/inventory", consumes = { "application/json" })
ResponseEntity<Void> addInventory(
		@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Inventory item to do") @Valid @RequestBody InventoryItem body);
 
Example #18
Source File: EntriesProxyResource.java    From browserup-proxy with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/assertStatusRedirection")
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "In case url pattern is provided assert that all responses " +
        "found by url pattern have statuses belonging to REDIRECTION class (3xx), otherwise " +
        "assert that all responses of current step have statuses belonging to REDIRECTION class (3xx)",
        responses = {@ApiResponse(
                description = "Assertion result",
                content = @Content(
                        mediaType = MediaType.APPLICATION_JSON,
                        schema = @Schema(implementation = AssertionResult.class)))})
public AssertionResult statusRedirection(
        @PathParam(PORT)
        @NotNullConstraint(paramName = PORT)
        @PortWithExistingProxyConstraint
        @Parameter(required = true, in = ParameterIn.PATH, description = DocConstants.PORT_DESCRIPTION) int port,

        @QueryParam(URL_PATTERN)
        @PatternConstraint(paramName = URL_PATTERN)
        @Parameter(description = DocConstants.URL_PATTERN_DESCRIPTION) String urlPattern) {

    MitmProxyServer proxyServer = proxyManager.get(port);

    return StringUtils.isEmpty(urlPattern) ?
            proxyServer.assertResponseStatusCode(HttpStatusClass.REDIRECTION) :
            proxyServer.assertResponseStatusCode(Pattern.compile(urlPattern), HttpStatusClass.REDIRECTION);
}
 
Example #19
Source File: HelloController.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(summary = "Get Something by key", responses = {
		@ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(oneOf = {
				String.class, Integer.class }), examples = {
				@ExampleObject(name = "The String example", value = "urgheiurgheirghieurg"),
				@ExampleObject(name = "The Integer example", value = "311414") })),
		@ApiResponse(responseCode = "404", description = "Thing not found"),
		@ApiResponse(responseCode = "401", description = "Authentication Failure") })
@GetMapping(value = "/hello")
ResponseEntity<Void> sayHello() {
	return null;
}
 
Example #20
Source File: StoreApi.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(summary = "Delete purchase order by ID", tags = { "store" })
@ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
		@ApiResponse(responseCode = "404", description = "Order not found") })
@DeleteMapping(value = "/store/order/{orderId}")
default ResponseEntity<Void> deleteOrder(
		@Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId) {
	return getDelegate().deleteOrder(orderId);
}
 
Example #21
Source File: HelloController.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@PostMapping(value = "/helloworld", produces = "application/json", consumes = "application/vnd.v1+json")
@ApiResponses({
		@ApiResponse(responseCode = "200", description = "Successful operation", content = @Content(schema = @Schema(implementation = HelloDTO1.class))),
		@ApiResponse(responseCode = "400", description = "Bad name", content = @Content(schema = @Schema(implementation = ErrorDTO.class))) })
public ResponseEntity<?> hello(@RequestBody RequestV1 request) {
	final String name = request.getNameV1();
	if ("error".equalsIgnoreCase(name)) {
		return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ErrorDTO("invalid name: " + name));
	}
	return ResponseEntity.ok(new HelloDTO1("Greetings from Spring Boot v1! " + name));
}
 
Example #22
Source File: PetApi.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(summary = "Update an existing pet", description = "", security = {
		@SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" })
@ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
		@ApiResponse(responseCode = "404", description = "Pet not found"),
		@ApiResponse(responseCode = "405", description = "Validation exception") })
@PutMapping(value = "/pet", consumes = { "application/json", "application/xml" })
default ResponseEntity<Void> updatePet(
		@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) {
	return getDelegate().updatePet(pet);
}
 
Example #23
Source File: EventsResource.java    From cantor with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@PUT
@Path("/{namespace}")
@Operation(summary = "Create an event namespace")
@ApiResponses(value = {
    @ApiResponse(responseCode = "200", description = "Event namespace was successfully created or already existed"),
    @ApiResponse(responseCode = "500", description = serverErrorMessage)
})
public Response createNamespace(@Parameter(description = "Namespace identifier") @PathParam("namespace") final String namespace) throws IOException {
    logger.info("received request for creation of namespace {}", namespace);
    this.cantor.events().create(namespace);
    return Response.ok().build();
}
 
Example #24
Source File: PetApi.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(summary = "Find pet by ID", description = "Returns a single pet", security = {
		@SecurityRequirement(name = "api_key") }, tags = { "pet" })
@ApiResponses(value = {
		@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))),
		@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
		@ApiResponse(responseCode = "404", description = "Pet not found") })
@GetMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" })
default ResponseEntity<Pet> getPetById(
		@Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") Long petId) {
	return getDelegate().getPetById(petId);
}
 
Example #25
Source File: UserApi.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(summary = "Logs user into the system", tags = { "user" })
@ApiResponses(value = {
		@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class))),
		@ApiResponse(responseCode = "400", description = "Invalid username/password supplied") })
@GetMapping(value = "/user/login", produces = { "application/xml", "application/json" })
default ResponseEntity<String> loginUser(
		@NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username,
		@NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) {
	return getDelegate().loginUser(username, password);
}
 
Example #26
Source File: UserApi.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(summary = "Updated user", tags = { "user" })
@ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid user supplied"),
		@ApiResponse(responseCode = "404", description = "User not found") })
@PutMapping(value = "/user/{username}", consumes = { "application/json" })
default ResponseEntity<Void> updateUser(
		@Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") String username,
		@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Updated user object", required = true) @Valid @RequestBody User user) {
	return getDelegate().updateUser(username, user);
}
 
Example #27
Source File: PetApi.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(summary = "uploads an image", description = "", security = {
		@SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" })
@ApiResponses(value = {
		@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) })
@PostMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = {
		"multipart/form-data" })
default ResponseEntity<ModelApiResponse> uploadFile(
		@Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") Long petId,
		@Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata,
		@Parameter(description = "file detail") @Valid @RequestPart("file") MultipartFile file) {
	return getDelegate().uploadFile(petId, additionalMetadata, file);
}
 
Example #28
Source File: PetApi.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
@Operation(summary = "uploads an image", description = "", security = {
		@SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" })
@ApiResponses(value = {
		@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) })
@PostMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = {
		"multipart/form-data" })
default ResponseEntity<ModelApiResponse> uploadFile(
		@Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") Long petId,
		@Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata,
		@Parameter(description = "file detail") @Valid @RequestPart("file") MultipartFile file) {
	return getDelegate().uploadFile(petId, additionalMetadata, file);
}
 
Example #29
Source File: MostRecentEntryProxyResource.java    From browserup-proxy with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/assertStatusServerError")
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "In case url pattern is provided assert that the most recent response " +
        "found by url pattern has status belonging to SERVER ERROR class (5xx), otherwise " +
        "assert that the most recent response has status belonging to SERVER ERROR class (5xx).",
        responses = {@ApiResponse(
                description = "Assertion result",
                content = @Content(
                        mediaType = MediaType.APPLICATION_JSON,
                        schema = @Schema(implementation = AssertionResult.class)))})
public AssertionResult statusServerError(
        @PathParam(PORT)
        @NotNullConstraint(paramName = PORT)
        @PortWithExistingProxyConstraint
        @Parameter(required = true, in = ParameterIn.PATH, description = PORT_DESCRIPTION) int port,

        @QueryParam(URL_PATTERN)
        @NotBlankConstraint(paramName = URL_PATTERN)
        @PatternConstraint(paramName = URL_PATTERN)
        @Parameter(description = URL_PATTERN_DESCRIPTION) String urlPattern) {

    MitmProxyServer proxyServer = proxyManager.get(port);

    return urlPattern.isEmpty() ?
            proxyServer.assertMostRecentResponseStatusCode(HttpStatusClass.SERVER_ERROR) :
            proxyServer.assertMostRecentResponseStatusCode(Pattern.compile(urlPattern), HttpStatusClass.SERVER_ERROR);
}
 
Example #30
Source File: MostRecentEntryProxyResource.java    From browserup-proxy with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/assertStatusSuccess")
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "In case url pattern is provided assert that the most recent response " +
        "found by url pattern has status belonging to SUCCESS class (2xx), otherwise " +
        "assert that the most recent response has status belonging to SUCCESS class (2xx).",
        responses = {@ApiResponse(
                description = "Assertion result",
                content = @Content(
                        mediaType = MediaType.APPLICATION_JSON,
                        schema = @Schema(implementation = AssertionResult.class)))})
public AssertionResult statusSuccess(
        @PathParam(PORT)
        @NotNullConstraint(paramName = PORT)
        @PortWithExistingProxyConstraint
        @Parameter(required = true, in = ParameterIn.PATH, description = PORT_DESCRIPTION) int port,

        @QueryParam(URL_PATTERN)
        @NotBlankConstraint(paramName = URL_PATTERN)
        @PatternConstraint(paramName = URL_PATTERN)
        @Parameter(description = URL_PATTERN_DESCRIPTION) String urlPattern) {

    MitmProxyServer proxyServer = proxyManager.get(port);

    return urlPattern.isEmpty() ?
            proxyServer.assertMostRecentResponseStatusCode(HttpStatusClass.SUCCESS) :
            proxyServer.assertMostRecentResponseStatusCode(Pattern.compile(urlPattern), HttpStatusClass.SUCCESS);
}