Skip to content

Commit 7cdaf6c

Browse files
authored
Merge pull request #13 from elibracha/sample
fixed Bugs on ORIGINAL openapi-diff-ignore
2 parents 25735a9 + f4c9836 commit 7cdaf6c

File tree

17 files changed

+321
-300
lines changed

17 files changed

+321
-300
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<groupId>com.github.elibracha</groupId>
3030
<artifactId>openapi-diff-ignore</artifactId>
31-
<version>2.2.8-SNAPSHOT</version>
31+
<version>2.3.1-SNAPSHOT</version>
3232

3333
<properties>
3434
<maven.compile.plugin.source>1.8</maven.compile.plugin.source>

samples/sample-api-first-approach/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
<dependency>
8989
<groupId>com.github.elibracha</groupId>
9090
<artifactId>openapi-diff</artifactId>
91-
<version>2.2.10</version>
91+
<version>2.3.0</version>
9292
<scope>test</scope>
9393
<exclusions>
9494
<exclusion>

samples/sample-api-first-approach/src/main/java/com/github/elibracha/samples/SampleApiFirstApproachApplication.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
@SpringBootApplication
77
public class SampleApiFirstApproachApplication {
88

9-
public static void main(String[] args) {
10-
SpringApplication.run(SampleApiFirstApproachApplication.class, args);
11-
}
9+
public static void main(String[] args) {
10+
SpringApplication.run(SampleApiFirstApproachApplication.class, args);
11+
}
1212

1313
}

samples/sample-api-first-approach/src/main/java/com/github/elibracha/samples/config/OpenApiConfig.java

Lines changed: 55 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,56 +20,64 @@
2020
@Configuration
2121
public class OpenApiConfig {
2222

23-
@Bean
24-
public GroupedOpenApi tempOpenApi1(@Qualifier("openApbCustomizerV1") OpenApiCustomiser openApiCustomiser) {
25-
String[] paths = {"/v1/**"};
26-
String[] packagedToMatch = {"com.github.elibracha.samples.controllers"};
27-
GroupedOpenApi openApi = GroupedOpenApi.builder().setGroup("v1").pathsToMatch(paths).packagesToScan(packagedToMatch).addOpenApiCustomiser(openApiCustomiser).build();
28-
return openApi;
29-
}
23+
@Bean
24+
public GroupedOpenApi tempOpenApi1(@Qualifier("openApbCustomizerV1") OpenApiCustomiser openApiCustomiser) {
25+
String[] paths = { "/v1/**" };
26+
String[] packagedToMatch = { "com.github.elibracha.samples.controllers" };
27+
GroupedOpenApi openApi = GroupedOpenApi.builder().setGroup("v1").pathsToMatch(paths)
28+
.packagesToScan(packagedToMatch).addOpenApiCustomiser(openApiCustomiser).build();
29+
return openApi;
30+
}
3031

31-
@Bean
32-
public GroupedOpenApi tempOpenApi2(@Qualifier("openApbCustomizerV2") OpenApiCustomiser openApiCustomiser) {
33-
String[] paths = {"/v2/**"};
34-
String[] packagedToMatch = {"com.github.elibracha.samples.controllers"};
35-
GroupedOpenApi openApi = GroupedOpenApi.builder().setGroup("v2").pathsToMatch(paths).packagesToScan(packagedToMatch).addOpenApiCustomiser(openApiCustomiser).build();
36-
return openApi;
37-
}
32+
@Bean
33+
public GroupedOpenApi tempOpenApi2(@Qualifier("openApbCustomizerV2") OpenApiCustomiser openApiCustomiser) {
34+
String[] paths = { "/v2/**" };
35+
String[] packagedToMatch = { "com.github.elibracha.samples.controllers" };
36+
GroupedOpenApi openApi = GroupedOpenApi.builder().setGroup("v2").pathsToMatch(paths)
37+
.packagesToScan(packagedToMatch).addOpenApiCustomiser(openApiCustomiser).build();
38+
return openApi;
39+
}
3840

39-
@Bean
40-
public OpenApiCustomiser openApbCustomizerV1() {
41-
return openApi -> {
42-
openApi.paths(removeSubstringVersionFromPath(openApi.getPaths()));
43-
openApi.info(new Info().title("OpenAPI PetStore - OpenAPI 3.0 - Version 1.0")
44-
.version("v1").description("PetStore Api version 1.0"));
45-
};
46-
}
41+
@Bean
42+
public OpenApiCustomiser openApbCustomizerV1() {
43+
return openApi -> {
44+
openApi.paths(removeSubstringVersionFromPath(openApi.getPaths()));
45+
openApi.info(new Info().title("OpenAPI PetStore - OpenAPI 3.0 - Version 1.0").version("v1")
46+
.description("PetStore Api version 1.0"));
47+
};
48+
}
4749

48-
@Bean
49-
public OpenApiCustomiser openApbCustomizerV2() {
50-
return openApi -> {
51-
openApi.paths(removeSubstringVersionFromPath(openApi.getPaths()));
52-
openApi.info(new Info().title("OpenAPI PetStore - OpenAPI 3.0 - Version 2.0")
53-
.version("v2").description("PetStore Api version 2.0"));
54-
};
55-
}
50+
@Bean
51+
public OpenApiCustomiser openApbCustomizerV2() {
52+
return openApi -> {
53+
openApi.paths(removeSubstringVersionFromPath(openApi.getPaths()));
54+
openApi.info(new Info().title("OpenAPI PetStore - OpenAPI 3.0 - Version 2.0").version("v2")
55+
.description("PetStore Api version 2.0"));
56+
};
57+
}
5658

57-
public Paths removeSubstringVersionFromPath(Paths openApiPaths) {
58-
Paths paths = new Paths();
59-
for (Map.Entry<String, PathItem> entry : openApiPaths.entrySet()) {
60-
int cut = entry.getKey().indexOf("/", entry.getKey().indexOf("/") + 1);
61-
paths.put(entry.getKey().substring(cut), entry.getValue());
62-
}
63-
return paths;
64-
}
59+
public Paths removeSubstringVersionFromPath(Paths openApiPaths) {
60+
Paths paths = new Paths();
61+
for (Map.Entry<String, PathItem> entry : openApiPaths.entrySet()) {
62+
int cut = entry.getKey().indexOf("/", entry.getKey().indexOf("/") + 1);
63+
paths.put(entry.getKey().substring(cut), entry.getValue());
64+
}
65+
return paths;
66+
}
6567

66-
@Bean
67-
public OpenAPI customOpenAPI() {
68-
return new OpenAPI().openapi("3.0.2")
69-
.components(new Components().addSecuritySchemes("api_key",
70-
new SecurityScheme().type(SecurityScheme.Type.APIKEY).name("api_key").in(SecurityScheme.In.HEADER))
71-
.addSecuritySchemes("petstore_auth", new SecurityScheme().type(SecurityScheme.Type.OAUTH2).flows(new OAuthFlows()
72-
.implicit(new OAuthFlow().authorizationUrl("https://petstore3.swagger.io/oauth/authorize")
73-
.scopes(new Scopes().addString("write:pets", "modify pets in your account").addString("read:pets", "read your pets"))))));
74-
}
68+
@Bean
69+
public OpenAPI customOpenAPI() {
70+
return new OpenAPI().openapi("3.0.2")
71+
.components(new Components()
72+
.addSecuritySchemes("api_key",
73+
new SecurityScheme().type(SecurityScheme.Type.APIKEY).name("api_key")
74+
.in(SecurityScheme.In.HEADER))
75+
.addSecuritySchemes("petstore_auth",
76+
new SecurityScheme().type(SecurityScheme.Type.OAUTH2)
77+
.flows(new OAuthFlows().implicit(new OAuthFlow()
78+
.authorizationUrl("https://petstore3.swagger.io/oauth/authorize")
79+
.scopes(new Scopes()
80+
.addString("write:pets", "modify pets in your account")
81+
.addString("read:pets", "read your pets"))))));
82+
}
7583
}

samples/sample-api-first-approach/src/main/java/com/github/elibracha/samples/controllers/v1/PetControllerV1.java

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,44 @@
1515
@RequestMapping("/v1")
1616
public class PetControllerV1 implements PetApi {
1717

18-
@Override
19-
public ResponseEntity<Pet> addPet(@Valid Pet pet) {
20-
return null;
21-
}
22-
23-
@Override
24-
public ResponseEntity<Void> deletePet(Long petId, String apiKey) {
25-
return null;
26-
}
27-
28-
@Override
29-
public ResponseEntity<List<Pet>> findPetsByStatus(@Valid String status) {
30-
return null;
31-
}
32-
33-
@Override
34-
public ResponseEntity<List<Pet>> findPetsByTags(@Valid List<String> tags) {
35-
return null;
36-
}
37-
38-
@Override
39-
public ResponseEntity<Pet> getPetById(Long petId) {
40-
return null;
41-
}
42-
43-
@Override
44-
public ResponseEntity<Pet> updatePet(@Valid Pet pet) {
45-
return null;
46-
}
47-
48-
@Override
49-
public ResponseEntity<Void> updatePetWithForm(Long petId, @Valid String name, @Valid String status) {
50-
return null;
51-
}
52-
53-
@Override
54-
public ResponseEntity<ModelApiResponse> uploadFile(Long petId, @Valid String additionalMetadata, @Valid Resource body) {
55-
return null;
56-
}
18+
@Override
19+
public ResponseEntity<Pet> addPet(@Valid Pet pet) {
20+
return null;
21+
}
22+
23+
@Override
24+
public ResponseEntity<Void> deletePet(Long petId, String apiKey) {
25+
return null;
26+
}
27+
28+
@Override
29+
public ResponseEntity<List<Pet>> findPetsByStatus(@Valid String status) {
30+
return null;
31+
}
32+
33+
@Override
34+
public ResponseEntity<List<Pet>> findPetsByTags(@Valid List<String> tags) {
35+
return null;
36+
}
37+
38+
@Override
39+
public ResponseEntity<Pet> getPetById(Long petId) {
40+
return null;
41+
}
42+
43+
@Override
44+
public ResponseEntity<Pet> updatePet(@Valid Pet pet) {
45+
return null;
46+
}
47+
48+
@Override
49+
public ResponseEntity<Void> updatePetWithForm(Long petId, @Valid String name, @Valid String status) {
50+
return null;
51+
}
52+
53+
@Override
54+
public ResponseEntity<ModelApiResponse> uploadFile(Long petId, @Valid String additionalMetadata,
55+
@Valid Resource body) {
56+
return null;
57+
}
5758
}

samples/sample-api-first-approach/src/main/java/com/github/elibracha/samples/controllers/v1/StoreControllerV1.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313
@RequestMapping("/v1")
1414
public class StoreControllerV1 implements StoreApi {
1515

16-
@Override
17-
public ResponseEntity<Void> deleteOrder(Long orderId) {
18-
return null;
19-
}
16+
@Override
17+
public ResponseEntity<Void> deleteOrder(Long orderId) {
18+
return null;
19+
}
2020

21-
@Override
22-
public ResponseEntity<Map<String, Integer>> getInventory() {
23-
return null;
24-
}
21+
@Override
22+
public ResponseEntity<Map<String, Integer>> getInventory() {
23+
return null;
24+
}
2525

26-
@Override
27-
public ResponseEntity<Order> getOrderById(Long orderId) {
28-
return null;
29-
}
26+
@Override
27+
public ResponseEntity<Order> getOrderById(Long orderId) {
28+
return null;
29+
}
3030

31-
@Override
32-
public ResponseEntity<Order> placeOrder(@Valid Order order) {
33-
return null;
34-
}
31+
@Override
32+
public ResponseEntity<Order> placeOrder(@Valid Order order) {
33+
return null;
34+
}
3535
}

samples/sample-api-first-approach/src/main/java/com/github/elibracha/samples/controllers/v1/UsersControllerV1.java

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,38 @@
1313
@RequestMapping("/v1")
1414
public class UsersControllerV1 implements UserApi {
1515

16-
@Override
17-
public ResponseEntity<User> createUser(@Valid User user) {
18-
return null;
19-
}
20-
21-
@Override
22-
public ResponseEntity<User> createUsersWithListInput(@Valid List<User> user) {
23-
return null;
24-
}
25-
26-
@Override
27-
public ResponseEntity<Void> deleteUser(String username) {
28-
return null;
29-
}
30-
31-
@Override
32-
public ResponseEntity<User> getUserByName(String username) {
33-
return null;
34-
}
35-
36-
@Override
37-
public ResponseEntity<String> loginUser(@Valid String username, @Valid String password) {
38-
return null;
39-
}
40-
41-
@Override
42-
public ResponseEntity<Void> logoutUser() {
43-
return null;
44-
}
45-
46-
@Override
47-
public ResponseEntity<Void> updateUser(String username, @Valid User user) {
48-
return null;
49-
}
16+
@Override
17+
public ResponseEntity<User> createUser(@Valid User user) {
18+
return null;
19+
}
20+
21+
@Override
22+
public ResponseEntity<User> createUsersWithListInput(@Valid List<User> user) {
23+
return null;
24+
}
25+
26+
@Override
27+
public ResponseEntity<Void> deleteUser(String username) {
28+
return null;
29+
}
30+
31+
@Override
32+
public ResponseEntity<User> getUserByName(String username) {
33+
return null;
34+
}
35+
36+
@Override
37+
public ResponseEntity<String> loginUser(@Valid String username, @Valid String password) {
38+
return null;
39+
}
40+
41+
@Override
42+
public ResponseEntity<Void> logoutUser() {
43+
return null;
44+
}
45+
46+
@Override
47+
public ResponseEntity<Void> updateUser(String username, @Valid User user) {
48+
return null;
49+
}
5050
}

0 commit comments

Comments
 (0)