use of io.swagger.models.ExternalDocs in project java-chassis by ServiceComb.
the class SwaggerDefinitionProcessor method convertExternalDocs.
private ExternalDocs convertExternalDocs(io.swagger.annotations.ExternalDocs annotationExternalDocs) {
ExternalDocs externalDocs = new ExternalDocs();
externalDocs.setUrl(annotationExternalDocs.url());
externalDocs.setDescription(annotationExternalDocs.value());
return externalDocs;
}
use of io.swagger.models.ExternalDocs in project swagger-core by swagger-api.
the class ModelSerializerTest method shouldNotCreateXmlObjectForRef.
@Test(description = "it should not create an xml object for ref")
public void shouldNotCreateXmlObjectForRef() throws IOException {
final RefModel model = new RefModel("Monster");
model.setDescription("oops");
model.setExternalDocs(new ExternalDocs("external docs", "http://swagger.io"));
assertEquals(Json.mapper().writeValueAsString(model), "{\"$ref\":\"#/definitions/Monster\"}");
}
use of io.swagger.models.ExternalDocs in project swagger-core by swagger-api.
the class ReaderTest method scanExternalDocsOnMethod.
@Test(description = "scan external docs on method")
public void scanExternalDocsOnMethod() {
Swagger swagger = getSwagger(ResourceWithExternalDocs.class);
ExternalDocs externalDocsForGet = swagger.getPath("/testString").getGet().getExternalDocs();
assertNull(externalDocsForGet);
ExternalDocs externalDocsForPost = swagger.getPath("/testString").getPost().getExternalDocs();
assertNotNull(externalDocsForPost);
assertEquals("Test Description", externalDocsForPost.getDescription());
assertEquals("https://swagger.io/", externalDocsForPost.getUrl());
}
use of io.swagger.models.ExternalDocs in project vertx-swagger by bobxwang.
the class Reader method readSwaggerConfig.
private void readSwaggerConfig(SwaggerDefinition config) {
readInfoConfig(config);
if (StringUtils.isNotBlank(config.basePath())) {
swagger.setBasePath(config.basePath());
}
if (StringUtils.isNotBlank(config.host())) {
swagger.setHost(config.host());
}
for (String consume : config.consumes()) {
if (StringUtils.isNotBlank(consume)) {
swagger.addConsumes(consume);
}
}
for (String produce : config.produces()) {
if (StringUtils.isNotBlank(produce)) {
swagger.addProduces(produce);
}
}
if (StringUtils.isNotBlank(config.externalDocs().value())) {
ExternalDocs externalDocs = swagger.getExternalDocs();
if (externalDocs == null) {
externalDocs = new ExternalDocs();
swagger.setExternalDocs(externalDocs);
}
externalDocs.setDescription(config.externalDocs().value());
if (StringUtils.isNotBlank(config.externalDocs().url())) {
externalDocs.setUrl(config.externalDocs().url());
}
}
for (OAuth2Definition oAuth2Config : config.securityDefinition().oAuth2Definitions()) {
io.swagger.models.auth.OAuth2Definition oAuth2Definition = new io.swagger.models.auth.OAuth2Definition();
OAuth2Definition.Flow flow = oAuth2Config.flow();
if (flow.equals(OAuth2Definition.Flow.ACCESS_CODE)) {
oAuth2Definition = oAuth2Definition.accessCode(oAuth2Config.authorizationUrl(), oAuth2Config.tokenUrl());
} else if (flow.equals(OAuth2Definition.Flow.APPLICATION)) {
oAuth2Definition = oAuth2Definition.application(oAuth2Config.tokenUrl());
} else if (flow.equals(OAuth2Definition.Flow.IMPLICIT)) {
oAuth2Definition = oAuth2Definition.implicit(oAuth2Config.authorizationUrl());
} else {
oAuth2Definition = oAuth2Definition.password(oAuth2Config.tokenUrl());
}
for (Scope scope : oAuth2Config.scopes()) {
oAuth2Definition.addScope(scope.name(), scope.description());
}
oAuth2Definition.setDescription(oAuth2Config.description());
swagger.addSecurityDefinition(oAuth2Config.key(), oAuth2Definition);
}
for (ApiKeyAuthDefinition[] apiKeyAuthConfigs : new ApiKeyAuthDefinition[][] { config.securityDefinition().apiKeyAuthDefintions(), config.securityDefinition().apiKeyAuthDefinitions() }) {
for (ApiKeyAuthDefinition apiKeyAuthConfig : apiKeyAuthConfigs) {
io.swagger.models.auth.ApiKeyAuthDefinition apiKeyAuthDefinition = new io.swagger.models.auth.ApiKeyAuthDefinition();
apiKeyAuthDefinition.setName(apiKeyAuthConfig.name());
apiKeyAuthDefinition.setIn(In.forValue(apiKeyAuthConfig.in().toValue()));
apiKeyAuthDefinition.setDescription(apiKeyAuthConfig.description());
swagger.addSecurityDefinition(apiKeyAuthConfig.key(), apiKeyAuthDefinition);
}
}
for (BasicAuthDefinition[] basicAuthConfigs : new BasicAuthDefinition[][] { config.securityDefinition().basicAuthDefinions(), config.securityDefinition().basicAuthDefinitions() }) {
for (BasicAuthDefinition basicAuthConfig : basicAuthConfigs) {
io.swagger.models.auth.BasicAuthDefinition basicAuthDefinition = new io.swagger.models.auth.BasicAuthDefinition();
basicAuthDefinition.setDescription(basicAuthConfig.description());
swagger.addSecurityDefinition(basicAuthConfig.key(), basicAuthDefinition);
}
}
for (io.swagger.annotations.Tag tagConfig : config.tags()) {
if (StringUtils.isNotBlank(tagConfig.name())) {
final Tag tag = new Tag();
tag.setName(tagConfig.name());
tag.setDescription(tagConfig.description());
if (StringUtils.isNotBlank(tagConfig.externalDocs().value())) {
tag.setExternalDocs(new ExternalDocs(tagConfig.externalDocs().value(), tagConfig.externalDocs().url()));
}
tag.getVendorExtensions().putAll(BaseReaderUtils.parseExtensions(tagConfig.extensions()));
swagger.addTag(tag);
}
}
for (SwaggerDefinition.Scheme scheme : config.schemes()) {
if (scheme != SwaggerDefinition.Scheme.DEFAULT) {
swagger.addScheme(Scheme.forValue(scheme.name()));
}
}
}
use of io.swagger.models.ExternalDocs in project incubator-servicecomb-java-chassis by apache.
the class SwaggerDefinitionProcessor method convertExternalDocs.
private ExternalDocs convertExternalDocs(io.swagger.annotations.ExternalDocs annotationExternalDocs) {
ExternalDocs externalDocs = new ExternalDocs();
externalDocs.setUrl(annotationExternalDocs.url());
externalDocs.setDescription(annotationExternalDocs.value());
return externalDocs;
}
Aggregations