View Javadoc
1   /*
2    * Copyright 2019 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.bremersee.spring.test.api.comparator;
18  
19  import io.swagger.v3.oas.annotations.Operation;
20  import io.swagger.v3.oas.annotations.Parameter;
21  import io.swagger.v3.oas.annotations.media.Content;
22  import io.swagger.v3.oas.annotations.media.Schema;
23  import io.swagger.v3.oas.annotations.responses.ApiResponse;
24  import io.swagger.v3.oas.annotations.responses.ApiResponses;
25  import io.swagger.v3.oas.annotations.tags.Tag;
26  import java.util.List;
27  import org.springframework.http.ResponseEntity;
28  import org.springframework.web.bind.annotation.GetMapping;
29  import org.springframework.web.bind.annotation.PathVariable;
30  import org.springframework.web.bind.annotation.PostMapping;
31  import org.springframework.web.bind.annotation.PutMapping;
32  import org.springframework.web.bind.annotation.RequestBody;
33  import org.springframework.web.bind.annotation.RequestMapping;
34  import org.springframework.web.bind.annotation.RequestMethod;
35  import org.springframework.web.bind.annotation.RequestParam;
36  
37  /**
38   * Bad apis for testing.
39   *
40   * @author Christian Bremer
41   */
42  public class BadApis {
43  
44    /**
45     * The interface One.
46     */
47    @Tag(name = "BadApiController")
48    public interface One {
49  
50    }
51  
52    /**
53     * The interface Two.
54     */
55    public interface Two {
56  
57    }
58  
59  
60    /**
61     * The interface Three.
62     */
63    @Tag(name = "BadApiController")
64    public interface Three {
65  
66      /**
67       * Gets models.
68       *
69       * @param query the query
70       * @return the models
71       */
72      @RequestMapping(
73          value = "/api/models",
74          produces = {"application/json"},
75          method = RequestMethod.GET)
76      ResponseEntity<List<ExampleModel>> getExampleModels(
77          @Parameter(description = "The query.") @RequestParam(name = "q", required = false)
78              String query);
79  
80      /**
81       * Update model response entity.
82       *
83       * @param id the id
84       * @param model the model
85       * @return the response entity
86       */
87      @PutMapping(path = "/api/models/{id}")
88      ResponseEntity<Void> updateExampleModel(
89          @PathVariable("id") String id,
90          @RequestBody ExampleModel model);
91  
92      /**
93       * Add model response entity.
94       *
95       * @param model the model
96       * @return the response entity
97       */
98      @PostMapping(path = "/api/models")
99      ResponseEntity<Void> addExampleModel(
100         @RequestBody ExampleModel model);
101 
102     /**
103      * Gets model.
104      *
105      * @param id the id
106      * @return the model
107      */
108     @Operation(
109         summary = "Get model by ID.",
110         operationId = "getExampleModel",
111         tags = {"model-controller"})
112     @ApiResponses(value = {
113         @ApiResponse(
114             responseCode = "200",
115             description = "OK",
116             content = @Content(schema = @Schema(implementation = ExampleModel.class)))
117     })
118     @GetMapping(path = "/api/models/{id}")
119     ResponseEntity<ExampleModel> getExampleModel(@PathVariable("id") String id);
120   }
121 
122   /**
123    * The interface Four.
124    */
125   @Tag(name = "BadApiController")
126   public interface Four {
127 
128     /**
129      * Update model response entity.
130      *
131      * @param model the model
132      * @return the response entity
133      */
134     @PutMapping(path = "/api/models/{id}")
135     ResponseEntity<Void> updateExampleModel(
136         @RequestBody ExampleModel model);
137 
138     /**
139      * Add model response entity.
140      *
141      * @param model the model
142      * @return the response entity
143      */
144     ResponseEntity<Void> addExampleModel(
145         @RequestBody ExampleModel model);
146 
147     /**
148      * Gets model.
149      *
150      * @param id the id
151      * @return the model
152      */
153     @Operation(
154         summary = "Get model by ID.",
155         operationId = "getExampleModel",
156         tags = {"model-controller"})
157     @ApiResponses(value = {
158         @ApiResponse(
159             responseCode = "200",
160             description = "OK",
161             content = @Content(schema = @Schema(implementation = String.class)))
162     })
163     @GetMapping(path = "/api/models/{id}")
164     ResponseEntity<String> getExampleModel(@PathVariable("id") String id);
165   }
166 
167 
168   /**
169    * The interface Five.
170    */
171   @Tag(name = "BadApiController")
172   public interface Five {
173 
174     /**
175      * Gets models.
176      *
177      * @param query the query
178      * @return the models
179      */
180     @RequestMapping(
181         value = "/api/models",
182         produces = {"application/json"},
183         method = RequestMethod.GET)
184     ResponseEntity<List<ExampleModel>> getExampleModels(
185         @Parameter(description = "The query.")
186         @RequestParam(name = "q", required = false) String query);
187   }
188 
189   /**
190    * The interface Six.
191    */
192   @Tag(name = "BadApiController")
193   public interface Six {
194 
195     /**
196      * Gets models.
197      *
198      * @param query the query
199      * @return the models
200      */
201     @GetMapping(
202         value = "/api/models",
203         produces = {"application/json"})
204     ResponseEntity<List<ExampleModel>> getExampleModels(
205         @Parameter(description = "The query.") @RequestParam(name = "q", required = false)
206             String query);
207   }
208 
209 
210   /**
211    * The interface Seven.
212    */
213   @Tag(name = "BadApiController")
214   public interface Seven {
215 
216     /**
217      * Gets models.
218      *
219      * @param query the query
220      * @return the models
221      */
222     @RequestMapping(
223         value = "/api/models",
224         produces = {"application/json"},
225         method = RequestMethod.GET)
226     ResponseEntity<List<ExampleModel>> getExampleModels(
227         @Parameter(description = "The query.") @RequestParam(name = "q", required = false)
228             String query);
229   }
230 
231   /**
232    * The interface Eight.
233    */
234   @Tag(name = "BadApiController")
235   public interface Eight {
236 
237     /**
238      * Gets models.
239      *
240      * @param query the query
241      * @return the models
242      */
243     @RequestMapping(
244         value = "/api/models",
245         produces = {"application/json"},
246         method = RequestMethod.GET)
247     ResponseEntity<List<ExampleModel>> getExampleModels(
248         @RequestParam(name = "q", required = false) String query);
249   }
250 
251 
252 }