本文整理了Java中io.swagger.models.Swagger.<init>()
方法的一些代码示例,展示了Swagger.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Swagger.<init>()
方法的具体详情如下:
包路径:io.swagger.models.Swagger
类名称:Swagger
方法名:<init>
暂无
代码示例来源:origin: blox/blox
@TaskAction
public void generateSpec() throws IOException, GenerateException {
ClassLoader loader = projectClassLoader();
Set<Class<?>> classes = new HashSet<>();
for (String pkg : apiPackages) {
Reflections reflections =
new Reflections(
new ConfigurationBuilder()
.addClassLoaders(loader)
.addUrls(ClasspathHelper.forPackage(pkg, loader))
.setExpandSuperTypes(false)
.filterInputsBy(new FilterBuilder().includePackage(pkg)));
Set<Class<?>> springMVCClasses =
reflections.getTypesAnnotatedWith(
org.springframework.web.bind.annotation.RestController.class);
classes.addAll(springMVCClasses);
}
SpringMvcApiReader reader = new SpringMvcApiReader(new Swagger(), log);
Swagger swagger = reader.read(classes);
for (SwaggerFilter filter : filters) {
filter.apply(swagger);
}
Yaml.pretty().writeValue(swaggerFile, swagger);
}
代码示例来源:origin: scouter-project/scouter
beanConfig.setScan(true);
Swagger swagger = new Swagger();
swagger.securityDefinition("Scouter auth token", new ApiKeyAuthDefinition("Authorization", In.HEADER));
new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
代码示例来源:origin: apache/servicecomb-java-chassis
public SwaggerGenerator(SwaggerGeneratorContext context, Class<?> cls) {
this.swagger = new Swagger();
this.context = context;
this.cls = cls;
this.classLoader = JvmUtils.findClassLoader();
this.packageName = "gen.swagger";
}
代码示例来源:origin: apache/servicecomb-java-chassis
public static Swagger parse(String content) {
try {
return Yaml.mapper().readValue(content, Swagger.class);
} catch (Exception e) {
return new Swagger();
// throw new Error(e);
}
}
代码示例来源:origin: Swagger2Markup/swagger2markup
@Test
public void testUriSchemeComponent() throws URISyntaxException {
Swagger swagger = new Swagger().host("http://localhost").basePath("/v2");
swagger.addScheme(Scheme.HTTP);
swagger.addScheme(Scheme.HTTPS);
Swagger2MarkupConverter.Context context = createContext();
MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();
markupDocBuilder = new UriSchemeComponent(context).apply(markupDocBuilder, UriSchemeComponent.parameters(swagger, OverviewDocument.SECTION_TITLE_LEVEL));
markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);
Path expectedFile = getExpectedFile(COMPONENT_NAME);
DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));
}
}
代码示例来源:origin: kongchen/swagger-maven-plugin
parameter.setName(propertyDescriptor.getDisplayName());
ParameterProcessor.applyAnnotations(new Swagger(), parameter, type, Lists.newArrayList(propertySetterApiParam));
代码示例来源:origin: stackoverflow.com
angular.module('swagger', []);
angular.module('swagger')
.factory('swaggerApi', function () {
return new Swagger({
url: 'http://localhost:8081/api-docs',
usePromise: true
});
});
代码示例来源:origin: kongchen/swagger-maven-plugin
protected Swagger read(Class<?> cls, String parentPath, String parentMethod, boolean readHidden, String[] parentConsumes,
String[] parentProduces, Map<String, Tag> parentTags, List<Parameter> parentParameters) {
if (swagger == null) {
swagger = new Swagger();
代码示例来源:origin: kongchen/swagger-maven-plugin
public AbstractDocumentSource(Log log, ApiSource apiSource) throws MojoFailureException {
LOG = log;
this.outputPath = apiSource.getOutputPath();
this.templatePath = apiSource.getTemplatePath();
this.swaggerPath = apiSource.getSwaggerDirectory();
this.modelSubstitute = apiSource.getModelSubstitute();
this.jsonExampleValues = apiSource.isJsonExampleValues();
swagger = new Swagger();
if (apiSource.getSchemes() != null) {
for (String scheme : apiSource.getSchemes()) {
swagger.scheme(Scheme.forValue(scheme));
}
}
// read description from file
if (apiSource.getDescriptionFile() != null) {
try {
InputStream is = new FileInputStream(apiSource.getDescriptionFile());
apiSource.getInfo().setDescription(IOUtils.toString(is));
is.close();
} catch (IOException e) {
throw new MojoFailureException(e.getMessage(), e);
}
}
swagger.setHost(apiSource.getHost());
swagger.setInfo(apiSource.getInfo());
swagger.setBasePath(apiSource.getBasePath());
swagger.setExternalDocs(apiSource.getExternalDocs());
this.apiSource = apiSource;
}
代码示例来源:origin: kongchen/swagger-maven-plugin
public Swagger read(SpringResource resource) {
if (swagger == null) {
swagger = new Swagger();
代码示例来源:origin: rakam-io/rakam
.url("http://www.apache.org/licenses/LICENSE-2.0.html"));
Swagger swagger = new Swagger().info(info)
.basePath("/")
.tags(ImmutableList.copyOf(tags))
代码示例来源:origin: io.swagger/swagger-jaxrs
public Swagger getSwagger() {
Swagger value = (Swagger) getConfigOrSwagger(true);
if (value == null && isServletConfigAvailable(sc)) {
value = (Swagger) sc.getServletContext().getAttribute("swagger");
}
if (value == null) value = new Swagger();
return value;
}
代码示例来源:origin: io.syndesis.server/server-connector-generator
@Test
public void shouldReturnNullIfNoHostGivenAnywhere() {
assertThat(determineHost(new Swagger())).isNull();
assertThat(determineHost(new Swagger().scheme(Scheme.HTTP))).isNull();
assertThat(determineHost(new Swagger().host("host"))).isNull();
}
代码示例来源:origin: io.syndesis.rest/rest-connector-generator
@Test
public void shouldDetermineHostFromSpecification() {
assertThat(determineHost(new Swagger().host("api.example.com").scheme(Scheme.HTTPS))).isEqualTo("https://api.example.com");
assertThat(determineHost(new Swagger().host("api.example.com").scheme(Scheme.HTTP).scheme(Scheme.HTTPS)))
.isEqualTo("https://api.example.com");
assertThat(determineHost(new Swagger().host("api.example.com").scheme(Scheme.HTTP))).isEqualTo("http://api.example.com");
}
代码示例来源:origin: io.syndesis.server/server-connector-generator
@Test
public void shouldDetermineConnectorName() {
final Swagger swagger = new Swagger();
assertThat(generator.determineConnectorName(SWAGGER_TEMPLATE, createSettingsFrom(swagger))).isEqualTo("unspecified");
final Info info = new Info();
swagger.info(info);
assertThat(generator.determineConnectorName(SWAGGER_TEMPLATE, createSettingsFrom(swagger))).isEqualTo("unspecified");
info.title("title");
assertThat(generator.determineConnectorName(SWAGGER_TEMPLATE, createSettingsFrom(swagger))).isEqualTo("title");
}
代码示例来源:origin: io.syndesis.server/server-api-generator
@Test
public void shouldDetermineConnectorDescription() {
final Swagger swagger = new Swagger();
assertThat(generator.determineConnectorDescription(SWAGGER_TEMPLATE, createSettingsFrom(swagger))).isEqualTo("unspecified");
final Info info = new Info();
swagger.info(info);
assertThat(generator.determineConnectorDescription(SWAGGER_TEMPLATE, createSettingsFrom(swagger))).isEqualTo("unspecified");
info.description("description");
assertThat(generator.determineConnectorDescription(SWAGGER_TEMPLATE, createSettingsFrom(swagger))).isEqualTo("description");
}
代码示例来源:origin: io.syndesis.server/server-connector-generator
@Test
public void shouldReturnNullIfNoHttpSchemesFound() {
assertThat(determineHost(new Swagger().scheme(Scheme.WS).scheme(Scheme.WSS))).isNull();
}
}
代码示例来源:origin: io.syndesis.rest/rest-connector-generator
@Test
public void shouldFailToDetermineIfNoHostGivenAnywhere() {
assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> determineHost(new Swagger()))
.withMessageStartingWith("Swagger specification does not provide");
assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> determineHost(new Swagger().scheme(Scheme.HTTP)))
.withMessageStartingWith("Swagger specification does not provide");
assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> determineHost(new Swagger().host("host")))
.withMessageStartingWith("Swagger specification does not provide");
}
}
代码示例来源:origin: io.syndesis.server/server-connector-generator
@Test
public void shouldMakeNonUniqueOperationIdsUnique() {
final Swagger swagger = new Swagger().path("/path", new Path().get(new Operation().operationId("foo"))
.post(new Operation().operationId("foo")).put(new Operation().operationId("bar")));
final Connector generated = generator.configureConnector(SWAGGER_TEMPLATE, new Connector.Builder().id("connector1").build(),
createSettingsFrom(swagger));
final List<ConnectorAction> actions = generated.getActions();
assertThat(actions).hasSize(3);
assertThat(actions.get(0).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo"));
assertThat(actions.get(1).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo1"));
assertThat(actions.get(2).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("bar"));
}
代码示例来源:origin: io.syndesis.server/server-api-generator
public SwaggerHelperOperationDescriptionGenerationTest(final String operationSummary, final String operationDescription,
final String expectedName, final String expectedDescription) {
operation = new Operation().description(operationDescription).summary(operationSummary);
swagger = new Swagger().path("/test", new Path().get(operation));
expected = new OperationDescription(expectedName, expectedDescription);
}
内容来源于网络,如有侵权,请联系作者删除!