-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
246 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...in/java/de/qaware/openapigeneratorforspring/common/supplier/DefaultOpenApiYamlMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*- | ||
* #%L | ||
* OpenAPI Generator for Spring Boot :: Common | ||
* %% | ||
* Copyright (C) 2020 QAware GmbH | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
package de.qaware.openapigeneratorforspring.common.supplier; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; | ||
import de.qaware.openapigeneratorforspring.model.OpenApi; | ||
|
||
import static com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature.MINIMIZE_QUOTES; | ||
import static com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature.WRITE_DOC_START_MARKER; | ||
|
||
public class DefaultOpenApiYamlMapper implements OpenApiYamlMapper { | ||
|
||
private static final ObjectMapper YAML_MAPPER = new YAMLMapper(new YAMLFactory()) | ||
.configure(MINIMIZE_QUOTES, true) | ||
.configure(WRITE_DOC_START_MARKER, false) | ||
.setSerializationInclusion(JsonInclude.Include.NON_NULL); | ||
|
||
|
||
@Override | ||
public String map(OpenApi openApi) throws JsonProcessingException { | ||
return YAML_MAPPER.writeValueAsString(openApi); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...r-for-spring-test/src/test/java/de/qaware/openapigeneratorforspring/test/app35/App35.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.qaware.openapigeneratorforspring.test.app35; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class App35 { | ||
public static void main(String[] args) { | ||
SpringApplication.run(App35.class, args); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...r-spring-test/src/test/java/de/qaware/openapigeneratorforspring/test/app35/App35Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package de.qaware.openapigeneratorforspring.test.app35; | ||
|
||
import de.qaware.openapigeneratorforspring.test.AbstractOpenApiGeneratorWebMvcBaseIntTest; | ||
import org.junit.Test; | ||
|
||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
public class App35Test extends AbstractOpenApiGeneratorWebMvcBaseIntTest { | ||
|
||
@Test | ||
public void getOpenApiAsJson_withAcceptTextHtml() throws Exception { | ||
performApiDocsRequest(x -> x.accept("text/html")) | ||
.andExpect(status().isNotAcceptable()); | ||
} | ||
|
||
@Test | ||
public void getOpenApiAsJson_withAcceptApplicationYaml() throws Exception { | ||
assertResponseBodyMatchesOpenApiYaml("app35.yaml", | ||
performApiDocsRequest(x -> x.accept("application/yaml")) | ||
); | ||
} | ||
|
||
@Test | ||
public void getOpenApiAsJson_withAcceptApplicationXYaml() throws Exception { | ||
assertResponseBodyMatchesOpenApiYaml("app35.yaml", | ||
performApiDocsRequest(x -> x.accept("application/x-yaml")) | ||
); | ||
} | ||
|
||
@Test | ||
public void getOpenApiAsJson_withAcceptTextYaml() throws Exception { | ||
assertResponseBodyMatchesOpenApiYaml("app35.yaml", | ||
performApiDocsRequest(x -> x.accept("text/yaml")) | ||
); | ||
} | ||
|
||
@Test | ||
public void getOpenApiAsJson_withAcceptTextXYaml() throws Exception { | ||
assertResponseBodyMatchesOpenApiYaml("app35.yaml", | ||
performApiDocsRequest(x -> x.accept("text/x-yaml")) | ||
); | ||
} | ||
|
||
@Test | ||
public void getOpenApiAsJson_withAcceptTextVndYaml() throws Exception { | ||
assertResponseBodyMatchesOpenApiYaml("app35.yaml", | ||
performApiDocsRequest(x -> x.accept("text/vnd.yaml")) | ||
); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...r-for-spring-test/src/test/java/de/qaware/openapigeneratorforspring/test/app36/App36.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.qaware.openapigeneratorforspring.test.app36; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class App36 { | ||
public static void main(String[] args) { | ||
SpringApplication.run(App36.class, args); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ng-test/src/test/java/de/qaware/openapigeneratorforspring/test/app36/App36Controller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package de.qaware.openapigeneratorforspring.test.app36; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class App36Controller { | ||
@GetMapping("mapping1") | ||
public String mapping1(@RequestBody String request, @RequestParam String param1) { | ||
return null; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...r-spring-test/src/test/java/de/qaware/openapigeneratorforspring/test/app36/App36Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package de.qaware.openapigeneratorforspring.test.app36; | ||
|
||
import de.qaware.openapigeneratorforspring.test.AbstractOpenApiGeneratorWebMvcBaseIntTest; | ||
import org.junit.Test; | ||
|
||
public class App36Test extends AbstractOpenApiGeneratorWebMvcBaseIntTest { | ||
|
||
@Test | ||
public void getOpenApiAsJson() throws Exception { | ||
assertResponseBodyMatchesOpenApiYaml("app36.yaml", | ||
performApiDocsRequest(x -> x.accept("application/yaml")) | ||
); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
openapi-generator-for-spring-test/src/test/resources/openApiYaml/app35.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: API for App35 | ||
version: unknown | ||
paths: { } |
Oops, something went wrong.