forked from federecio/dropwizard-swagger
-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #327 from aurobindoc/3.0.x
Add servers in SwaggerBundleConfiguration
- Loading branch information
Showing
3 changed files
with
85 additions
and
1 deletion.
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
51 changes: 51 additions & 0 deletions
51
src/test/java/io/federecio/dropwizard/swagger/DefaultServerWithServerConfigTest.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,51 @@ | ||
/* | ||
* Copyright © 2014 Federico Recio (N/A) | ||
* | ||
* 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. | ||
*/ | ||
package io.federecio.dropwizard.swagger; | ||
|
||
import io.dropwizard.testing.ResourceHelpers; | ||
import io.dropwizard.testing.junit5.DropwizardAppExtension; | ||
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport; | ||
import io.restassured.RestAssured; | ||
import org.eclipse.jetty.http.HttpStatus; | ||
import org.hamcrest.core.StringContains; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
@ExtendWith(DropwizardExtensionsSupport.class) | ||
public class DefaultServerWithServerConfigTest extends DropwizardTest { | ||
|
||
private static DropwizardAppExtension<TestConfiguration> RULE = | ||
new DropwizardAppExtension<>( | ||
TestApplication.class, ResourceHelpers.resourceFilePath("test-default-server.yaml")); | ||
|
||
public DefaultServerWithServerConfigTest() { | ||
super(RULE.getLocalPort(), "/"); | ||
} | ||
|
||
@Test | ||
@Disabled("passes when ran standalone, but fails inside the suite") | ||
public void swaggerHasContactInfo() throws Exception { | ||
RestAssured.expect() | ||
.statusCode(HttpStatus.OK_200) | ||
.body( | ||
StringContains.containsString("\"name\":\"test-contact-info\""), | ||
StringContains.containsString("\"email\":\"[email protected]\""), | ||
StringContains.containsString("\"url\":\"test-url.contact.com\"")) | ||
.when() | ||
.get(Path.from(basePath, "openapi.json")); | ||
} | ||
} |
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,17 @@ | ||
server: | ||
type: default | ||
applicationConnectors: | ||
- type: http | ||
port: 0 | ||
adminConnectors: | ||
- type: http | ||
port: 0 | ||
swagger: | ||
resourcePackage: io.federecio.dropwizard.swagger | ||
servers: | ||
- url: https://development.example.com/ | ||
description: Development server | ||
- url: https://staging.example.com/v1 | ||
description: Staging server | ||
- url: https://api.example.com/v1 | ||
description: Production server |