org.joinedworkz.common.OpenApiCartridge Maven / Gradle / Ivy
package org.joinedworkz.common;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.xtext.xbase.lib.Extension;
import org.joinedworkz.common.generator.CmnOpenApiGenerator;
import org.joinedworkz.common.helper.CmnModelHelper;
import org.joinedworkz.core.facility.AbstractCartridge;
import org.joinedworkz.core.facility.Outlet;
import org.joinedworkz.core.facility.Outlets;
import org.joinedworkz.core.model.CmnModel;
import org.joinedworkz.core.model.CmnObject;
@Singleton
@SuppressWarnings("all")
public class OpenApiCartridge extends AbstractCartridge {
@Inject
@Extension
protected CmnModelHelper cmnModelHelper;
@Inject
protected CmnOpenApiGenerator openApiGenerator;
@Override
public void apply(final CmnObject obj, final Outlets osa) {
final Outlet openApiOutlet = osa.get("generatedOpenApi");
if ((obj instanceof CmnModel)) {
this.generateOpenApi(((CmnModel)obj), openApiOutlet);
}
}
public void generateOpenApi(final CmnModel model, final Outlet openApiOutlet) {
this.openApiGenerator.generateOpenApiYml(this.createGeneratorContext(model, openApiOutlet));
}
public OpenApiGeneratorContext createGeneratorContext(final CmnModel model, final Outlet outlet) {
return new OpenApiGeneratorContext(model, outlet);
}
}