protected void init() { Pair<List<Tag>, Map<String, Path>> tagsAndPaths = generatePaths(); swagger = new Swagger() .host(getHost()) .basePath(getBasePath()) .consumes(APPLICATION_JSON_VALUE) .produces(APPLICATION_JSON_VALUE) .info(generateInfo()) .tags(tagsAndPaths.getFirst()) .paths(tagsAndPaths.getSecond()); swagger.setParameters(parameters); swagger.setDefinitions(definitions); }
String s = getString(n, location + ".consumes", result); if (s != null) { swagger.consumes(s);
@Test public void swaggerSerializeTest() { final Info info = new Info().version("1.0.0").title("Swagger WebServices REST"); Swagger swagger = new Swagger().info(info).securityDefinition("basicAuth", new BasicAuthDefinition()) .scheme(Scheme.HTTP).consumes("application/json").produces("application/json"); final Model patientModel = ModelConverters.getInstance().read(Patient.class).get("Patient"); swagger.addDefinition("Patient", patientModel); final String swaggerJson = Json.pretty(swagger); assertNotNull(swaggerJson); }
private void initSwagger() { final Info info = new Info() .version(OpenmrsConstants.OPENMRS_VERSION_SHORT) .title("OpenMRS API Docs") .description("OpenMRS RESTful API documentation generated by Swagger") .contact(new Contact().name("OpenMRS").url("http://openmrs.org")) .license(new License().name("MPL-2.0 w/ HD").url("http://openmrs.org/license")); swagger .info(info) .host(this.host) .basePath(this.basePath) .schemes(this.schemes) .securityDefinition("basic_auth", new BasicAuthDefinition()) .security(new SecurityRequirement().requirement("basic_auth")) .consumes("application/json") .produces("application/json") .externalDocs(new ExternalDocs() .description("Find more info on REST Module Wiki") .url("https://wiki.openmrs.org/x/xoAaAQ")); }