use of io.swagger.v3.jaxrs2.resources.model.Tag in project flow by vaadin.
the class OpenAPIObjectGenerator method addTagsInformation.
private void addTagsInformation() {
for (Map.Entry<ClassOrInterfaceDeclaration, String> endpointJavadoc : endpointsJavadoc.entrySet()) {
Tag tag = new Tag();
ClassOrInterfaceDeclaration endpointDeclaration = endpointJavadoc.getKey();
String simpleClassName = endpointDeclaration.getNameAsString();
tag.name(simpleClassName);
tag.description(endpointJavadoc.getValue());
tag.addExtension(EXTENSION_VAADIN_FILE_PATH, qualifiedNameToPath.get(endpointDeclaration.getFullyQualifiedName().orElse(simpleClassName)));
openApiModel.addTagsItem(tag);
}
}
use of io.swagger.v3.jaxrs2.resources.model.Tag in project flow by vaadin.
the class CodeGenerator method postProcessOperations.
@Override
@SuppressWarnings("unchecked")
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
String classname = (String) operations.get("classname");
for (Tag tag : tags) {
if (tag.getName().equals(classname)) {
objs.put(VAADIN_CONNECT_CLASS_DESCRIPTION, tag.getDescription());
setVaadinFilePath(objs, tag);
break;
}
}
if (objs.get(VAADIN_CONNECT_CLASS_DESCRIPTION) == null) {
logger.debug("The class '{}' doesn't have JavaDoc or it is invalid. This results in no TsDoc for the generated module '{}'.", classname, classname);
}
if ((operations.get(OPERATION) instanceof List)) {
List<CodegenOperation> codegenOperations = (List<CodegenOperation>) operations.get(OPERATION);
setShouldShowTsDoc(codegenOperations);
}
Map<String, Object> postProcessOperations = super.postProcessOperations(objs);
List<Map<String, Object>> imports = (List<Map<String, Object>>) objs.get("imports");
adjustImportInformationForEndpoints(imports);
printDebugMessage(postProcessOperations, "=== All operations data ===");
return postProcessOperations;
}
use of io.swagger.v3.jaxrs2.resources.model.Tag in project cxf by apache.
the class OpenApiCustomizer method customize.
public void customize(final OpenAPI oas) {
if (replaceTags || javadocProvider != null) {
Map<String, ClassResourceInfo> operations = new HashMap<>();
Map<Pair<String, String>, OperationResourceInfo> methods = new HashMap<>();
cris.forEach(cri -> {
cri.getMethodDispatcher().getOperationResourceInfos().forEach(ori -> {
String normalizedPath = getNormalizedPath(cri.getURITemplate().getValue(), ori.getURITemplate().getValue());
operations.put(normalizedPath, cri);
methods.put(Pair.of(ori.getHttpMethod(), normalizedPath), ori);
});
});
List<Tag> tags = new ArrayList<>();
oas.getPaths().forEach((pathKey, pathItem) -> {
Optional<Tag> tag;
if (replaceTags && operations.containsKey(pathKey)) {
ClassResourceInfo cri = operations.get(pathKey);
tag = Optional.of(new Tag());
tag.get().setName(cri.getURITemplate().getValue().replaceAll("/", "_"));
if (javadocProvider != null) {
tag.get().setDescription(javadocProvider.getClassDoc(cri));
}
if (!tags.contains(tag.get())) {
tags.add(tag.get());
}
} else {
tag = Optional.empty();
}
pathItem.readOperationsMap().forEach((method, operation) -> {
if (replaceTags && tag.isPresent()) {
operation.setTags(Collections.singletonList(tag.get().getName()));
}
Pair<String, String> key = Pair.of(method.name(), pathKey);
if (methods.containsKey(key) && javadocProvider != null) {
OperationResourceInfo ori = methods.get(key);
if (StringUtils.isBlank(operation.getSummary())) {
operation.setSummary(javadocProvider.getMethodDoc(ori));
}
if (operation.getParameters() == null) {
List<Parameter> parameters = new ArrayList<>();
addParameters(parameters);
operation.setParameters(parameters);
}
for (int i = 0; i < operation.getParameters().size(); i++) {
if (StringUtils.isBlank(operation.getParameters().get(i).getDescription())) {
operation.getParameters().get(i).setDescription(extractJavadoc(operation, ori, i));
}
}
addParameters(operation.getParameters());
customizeResponses(operation, ori);
}
});
});
if (replaceTags && oas.getTags() != null) {
oas.setTags(tags);
}
}
}
use of io.swagger.v3.jaxrs2.resources.model.Tag in project snow-owl by b2ihealthcare.
the class VersionRestService method createVersion.
@Operation(summary = "Create a new resource version", description = "Creates a new resource version. " + "The version tag (represented by an empty branch) is created on the resource's current working branch. " + "Where applicable, effective times are set on the unpublished content as part of this operation.")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Created"), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "409", description = "Code system version conflicts with existing branch") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(value = HttpStatus.CREATED)
public ResponseEntity<Void> createVersion(@Parameter(description = "Version parameters") @RequestBody final ResourceRequest<VersionRestInput> input) {
final VersionRestInput change = input.getChange();
ApiValidation.checkInput(change);
String newVersionUri = String.join(Branch.SEPARATOR, change.getResource().toString(), change.getVersion());
String jobId = ResourceRequests.prepareNewVersion().setResource(change.getResource()).setVersion(change.getVersion()).setDescription(change.getDescription()).setEffectiveTime(change.getEffectiveTime()).setForce(change.isForce()).setCommitComment(input.getCommitComment()).buildAsync().runAsJobWithRestart(ResourceRequests.versionJobKey(change.getResource()), "Creating version " + newVersionUri).execute(getBus()).getSync(1, TimeUnit.MINUTES);
RemoteJobEntry job = JobRequests.waitForJob(getBus(), jobId, 500);
if (job.isSuccessful()) {
final URI location = MvcUriComponentsBuilder.fromMethodName(VersionRestService.class, "getVersion", newVersionUri).build().toUri();
return ResponseEntity.created(location).build();
} else if (!Strings.isNullOrEmpty(job.getResult())) {
ApiError error = job.getResultAs(ApplicationContext.getServiceForClass(ObjectMapper.class), ApiError.class);
throw new ApiErrorException(error.withMessage(error.getMessage().replace("Branch name", "Version")));
} else {
throw new SnowowlRuntimeException("Version creation failed.");
}
}
use of io.swagger.v3.jaxrs2.resources.model.Tag in project swagger-parser by swagger-api.
the class OpenAPIDeserializerTest method readTagObject.
@Test(dataProvider = "data")
public void readTagObject(JsonNode rootNode) throws Exception {
final OpenAPIDeserializer deserializer = new OpenAPIDeserializer();
final SwaggerParseResult result = deserializer.deserialize(rootNode);
Assert.assertNotNull(result);
final OpenAPI openAPI = result.getOpenAPI();
Assert.assertNotNull(openAPI);
final List<Tag> Tag = openAPI.getTags();
Assert.assertNotNull(Tag);
Assert.assertNotNull(Tag.get(0));
Assert.assertNotNull(Tag.get(0).getName());
Assert.assertEquals(Tag.get(0).getName(), "pet");
Assert.assertNotNull(Tag.get(0).getDescription());
Assert.assertEquals(Tag.get(0).getDescription(), "Everything about your Pets");
Assert.assertNotNull(Tag.get(0).getExternalDocs());
Assert.assertNotNull(Tag.get(1));
Assert.assertNotNull(Tag.get(1).getName());
Assert.assertNotNull(Tag.get(1).getDescription());
Assert.assertEquals(Tag.get(1).getName(), "store");
Assert.assertEquals(Tag.get(1).getDescription(), "Access to Petstore orders");
}
Aggregations