Java Code Examples for org.eclipse.microprofile.openapi.models.OpenAPI#getPaths()
The following examples show how to use
org.eclipse.microprofile.openapi.models.OpenAPI#getPaths() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModelUtil.java From smallrye-open-api with Apache License 2.0 | 5 votes |
/** * Gets the {@link Paths} from the OAI model. If it doesn't exist, creates it. * * @param openApi OpenAPI * @return Paths */ public static Paths paths(OpenAPI openApi) { if (openApi.getPaths() == null) { openApi.setPaths(new PathsImpl()); } return openApi.getPaths(); }
Example 2
Source File: AnnotationScanner.java From smallrye-open-api with Apache License 2.0 | 5 votes |
/** * Now that all paths have been created, sort them. * (we don't have a better way to organize them) * * @param openApi the openApi model */ default void sortPaths(OpenAPI openApi) { Paths paths = openApi.getPaths(); if (paths != null) { Paths sortedPaths = new PathsImpl(); TreeSet<String> sortedKeys = new TreeSet<>(paths.getPathItems().keySet()); for (String pathKey : sortedKeys) { PathItem pathItem = paths.getPathItem(pathKey); sortedPaths.addPathItem(pathKey, pathItem); } sortedPaths.setExtensions(paths.getExtensions()); openApi.setPaths(sortedPaths); } }
Example 3
Source File: OpenApiDocument.java From smallrye-open-api with Apache License 2.0 | 4 votes |
public void initialize() { synchronized (INSTANCE) { if (model != null) { modelAlreadyInitialized(); } // Check all the required parts are set if (config == null) { throw ApiMessages.msg.configMustBeSet(); } // Phase 1: Use OASModelReader OpenAPI merged = readerModel; // Phase 2: Merge any static OpenAPI file packaged in the app merged = MergeUtil.mergeObjects(merged, staticFileModel); // Phase 3: Merge annotations merged = MergeUtil.mergeObjects(merged, annotationsModel); // Phase 4: Filter model via OASFilter merged = filterModel(merged); // Phase 5: Default empty document if model == null if (merged == null) { merged = new OpenAPIImpl(); merged.setOpenapi(OpenApiConstants.OPEN_API_VERSION); } // Phase 6: Provide missing required elements if (merged.getPaths() == null) { merged.setPaths(new PathsImpl()); } if (merged.getInfo() == null) { merged.setInfo(new InfoImpl()); } if (merged.getInfo().getTitle() == null) { merged.getInfo().setTitle((archiveName == null ? "Generated" : archiveName) + " API"); } if (merged.getInfo().getVersion() == null) { merged.getInfo().setVersion("1.0"); } // Phase 7: Use Config values to add Servers (global, pathItem, operation) ServersUtil.configureServers(config, merged); model = merged; clear(); } }