Writing REST API with OpenAPI and SpringBoot

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • openapi-generator

    OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

  • /** * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (5.4.0). * https://openapi-generator.tech * Do not edit the class manually. */ package com.sab.inventory.api; import com.sab.inventory.dto.Error; import com.sab.inventory.dto.Product; import java.util.UUID; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; import javax.validation.constraints.*; import java.util.List; import java.util.Map; import java.util.Optional; import javax.annotation.Generated; @Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2022-04-23T22:00:49.464591+02:00[Europe/Berlin]") @Validated @Tag(name = "products", description = "the products API") public interface ProductsApi { /** * POST /products * Add A Product to inventory * * @param product (optional) * @return All products are returned (status code 201) * or No Product returned (status code 400) */ @Operation( operationId = "addProduct", responses = { @ApiResponse(responseCode = "201", description = "All products are returned", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Product.class))), @ApiResponse(responseCode = "400", description = "No Product returned", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class))) } ) @RequestMapping( method = RequestMethod.POST, value = "/products", produces = { "application/json" }, consumes = { "application/json" } ) ResponseEntity addProduct( @Parameter(name = "Product", description = "", schema = @Schema(description = "")) @Valid @RequestBody(required = false) Product product ); /** * GET /products * Get All Products * * @return All products are returned (status code 200) * or No Product returned (status code 404) */ @Operation( operationId = "getAllProducts", responses = { @ApiResponse(responseCode = "200", description = "All products are returned", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Product.class))), @ApiResponse(responseCode = "404", description = "No Product returned", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class))) } ) @RequestMapping( method = RequestMethod.GET, value = "/products", produces = { "application/json" } ) ResponseEntity> getAllProducts( ); /** * GET /products/{id} * Get A Product By ID * * @param id (required) * @return All products are returned (status code 200) * or No Product returned (status code 404) */ @Operation( operationId = "getProductById", responses = { @ApiResponse(responseCode = "200", description = "All products are returned", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Product.class))), @ApiResponse(responseCode = "404", description = "No Product returned", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class))) } ) @RequestMapping( method = RequestMethod.GET, value = "/products/{id}", produces = { "application/json" } ) ResponseEntity getProductById( @Parameter(name = "id", description = "", required = true, schema = @Schema(description = "")) @PathVariable("id") UUID id ); /** * PUT /products/{id} * Update A Product * * @param id (required) * @param product (optional) * @return Created product is returned (status code 200) * or Error (status code 400) * or Product Does not Exist (status code 404) */ @Operation( operationId = "updateProduct", responses = { @ApiResponse(responseCode = "200", description = "Created product is returned", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Product.class))), @ApiResponse(responseCode = "400", description = "Error", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class))), @ApiResponse(responseCode = "404", description = "Product Does not Exist", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class))) } ) @RequestMapping( method = RequestMethod.PUT, value = "/products/{id}", produces = { "application/json" }, consumes = { "application/json" } ) ResponseEntity updateProduct( @Parameter(name = "id", description = "", required = true, schema = @Schema(description = "")) @PathVariable("id") UUID id, @Parameter(name = "Product", description = "", schema = @Schema(description = "")) @Valid @RequestBody(required = false) Product product ); }

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts