private void walkParameter(Parameter parameter) { // parameter has already been visited if (parameter instanceof BodyParameter) { callbacks.bodyParameter((BodyParameter) parameter); walkBodyParameter((BodyParameter) parameter); } else if (parameter instanceof SerializableParameter) { walkSerializableParameter((SerializableParameter) parameter); } }
private void sortTree(ObjectNode tree) { if (options.isAsDeclaredOrdering()) { // nothing to do } else if (options.isSortedOrdering()) { sort(tree); } }
public void setTypeNames(boolean setMissingTitles) { for (Content contentItem : contentManager.contentItems()) { setTypeNames(contentItem, setMissingTitles); } }
public static void removeUnresolvableRef(Object item) { RepreZenVendorExtension rzve = RepreZenVendorExtension.get(item); if (rzve != null) { rzve.setUnresolvableRef(null).setReason(null).set(item); RepreZenVendorExtension.removeIfEmpty(item); } }
/** * Recursive method to search out and handle all references in this loaded spec */ private JsonNode assembleNode(JsonNode node, Reference base, Set<Reference> visited) { if (Util.isRef(node)) { Reference ref = Reference.fromNode(node, base, contentManager.getModelVersion()); return assembleRef(ref, base, visited); } else { assembleObjectProperties(node, base, visited); assembleArrayElements(node, base, visited); return node; } }
public void retainImplicitlyReferencedObjects() { for (LocalContent item : localizer.getLocalContentItems()) { if (item.isRetained()) { if (item.getSectionType() == ObjectType.PATH && item.isRetained()) { getRequiredSecuritySchemesFromPath(item).forEach(LocalContent::retain); } } else if (item.getSectionType() == ObjectType.SECURITY_SCHEME) { item.retain(); } } }
private void retainObjectsInSection(Content content, ObjectType section) { for (String objectName : content.getObjectNames(section)) { Reference ref = content.getObjectReference(section, objectName); JsonNode obj = content.getObject(section, objectName).get(); localizer.register(ref, obj).retain(); } }
public JsonNode getLocalizedRefNode(Reference ref) { Optional<JsonNode> node = getModelObject(ref); if (node.isPresent()) { localizer.register(ref, node.get()); return localizer.getLocalizedRefNode(ref); } else { return ref.getBadRefNode(); } }
public Reference getLocalizedRef(Reference ref) { Optional<JsonNode> node = getModelObject(ref); if (node.isPresent()) { localizer.register(ref, node.get()); return localizer.getLocalizedRef(ref); } else { return ref.getBadRef(); } }
/** * Localize all the model objects in the given content item * <p> * This is used when to ensure that all model objects appearing in the top-level * spec will retain their original names in the final spec. Model objects * appearing in other specs may have their names changed for disambiguation. */ public void localizeObjects(Content content) { for (ObjectType section : ObjectType.getTypesForVersion(modelVersion, Option.COMPONENT_OBJECTS)) { localizeObjectsInSection(content, section); } localizeObjectsInSection(content, ObjectType.PATH); }
public OpenApiReferenceProcessor(Options options) { this.options = options; this.modelVersion = options.getModelVersion(); this.contentManager = new ContentManager(modelVersion); }
public static void removeMarkers(Swagger model, final Options options) { if (!options.isRetainAllExtensionData()) { SwaggerWalker.walk(model, new SwaggerWalker.Callbacks() { @Override public void any(Object obj) { removeItemMarkers(obj, options); } }); } }
public ContentLoader(ContentManager contentManager) { this.contentManager = contentManager; this.docLoader = new DocLoader(contentManager.getModelVersion()); }
private static void hoistParameter(Parameter pathParameter, List<Operation> operations) { if (operations != null) { for (Operation operation : operations) { hoistParameter(pathParameter, operation); } } }
/** * Create a content object for a URL that cannot be loaded. */ public static Content getUnloadableContentItem(Reference reference, String unloadableReason) { return new Content(reference, null, unloadableReason); }
/** * This private load method is used to load documents directly or indirectly * referenced by the top-level document. A preloaded tree is never provided in * this case. */ private Content loadRequestedDoc(URL url, boolean rewriteSimpleRefs) { return loadInternal(url, null, rewriteSimpleRefs); }
public LocalContent(Reference ref, JsonNode node) { this.ref = ref; this.content = node; this.name = chooseLocalName(); this.position = ContentLocalizer.this.nextPositionValue++; }
private Content(Reference reference, JsonNode content, String unloadableReason) { this.ref = reference; this.tree = content; this.unloadableReason = unloadableReason; this.version = ref.getModelVersion(); }
public String getCanonicalRefString() { if (fragment == null) { return getCanonicalFileRefString(); } else { return getCanonicalFileRefString() + "#" + fragment; } }
public static void fixTypes(Swagger swagger) { SwaggerWalker.walk(swagger, new SwaggerWalker.Callbacks() { @Override public void objectModel(ModelImpl objectModel) { if (objectModel.getType() == null) { objectModel.setType("object"); } } }); } }