All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.swagger.codegen.v3.ISchemaHandler Maven / Gradle / Ivy

There is a newer version: 3.0.62
Show newest version
package io.swagger.codegen.v3;

import io.swagger.v3.oas.models.media.Schema;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public interface ISchemaHandler {

    default void readProcessedModels(Map allProcessedModels) {
        final List codegenSchemas = new ArrayList<>();
        final Map allModels = new HashMap<>();
        for (String name : allProcessedModels.keySet()) {
            final Map modelMap = (Map) allProcessedModels.get(name);
            final List> models = (List>) modelMap.get("models");
            for (Map mo : models) {
                final CodegenModel codegenModel = (CodegenModel) mo.get("model");
                final Schema schema = (Schema) mo.get("schema");

                codegenSchemas.add(new CodegenSchema(codegenModel, schema));
                allModels.put(codegenModel.classname, codegenModel);
            }
        }
        if (codegenSchemas.isEmpty()) {
            return;
        }
        for (CodegenSchema codegenSchema : codegenSchemas) {
            processComposedSchemas(codegenSchema.getCodegenModel(), codegenSchema.getSchema(), allModels);
        }
    }

    /**
     * check if there is any composed schema in models or properties. And create codegen model objects if it's required.
     * @param codegenModel
     * @param schema
     */
    void processComposedSchemas(CodegenModel codegenModel, Schema schema, Map allModels);

    /**
     * retrieve a list of codegen models created from composed schemas found.
     * @return
     */
    List getModels();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy