remove dir

This commit is contained in:
sanitaso 2022-03-08 15:13:42 +01:00
parent a735229a84
commit bc543e9c79
4 changed files with 0 additions and 100 deletions

View File

@ -1,13 +0,0 @@
package com.baeldung.swaggerresponseapi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SwaggerResponseApiApplication {
public static void main(String[] args) {
SpringApplication.run(SwaggerResponseApiApplication.class, args);
}
}

View File

@ -1,38 +0,0 @@
package com.baeldung.swaggerresponseapi.controller;
import com.baeldung.swaggerresponseapi.model.Product;
import com.baeldung.swaggerresponseapi.service.ProductService;
import io.swagger.v3.oas.annotations.media.ArraySchema;
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.responses.ApiResponses;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class ProductController {
private final ProductService productService;
public ProductController(ProductService productService) {
this.productService = productService;
}
@PostMapping("/create")
public Product addProduct(@RequestBody Product product) {
return productService.addProducts(product);
}
@ApiResponses(value = { @ApiResponse(content = { @Content(mediaType = "application/json",
array = @ArraySchema(schema = @Schema(implementation = Product.class))) }) })
@GetMapping("/products")
public List<Product> getProductsList() {
return productService.getProductsList();
}
}

View File

@ -1,28 +0,0 @@
package com.baeldung.swaggerresponseapi.model;
public class Product {
String code;
String name;
public Product(String code, String name) {
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -1,21 +0,0 @@
package com.baeldung.swaggerresponseapi.service;
import com.baeldung.swaggerresponseapi.model.Product;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class ProductService {
List<Product> productsList = new ArrayList<>();
public Product addProducts(Product product) {
productsList.add(product);
return product;
}
public List<Product> getProductsList() {
return productsList;
}
}