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

org.joinedworkz.common.OpenApiCartridge.xtend Maven / Gradle / Ivy

package org.joinedworkz.common

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
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class OpenApiCartridge extends AbstractCartridge {
	
	@Inject
	protected extension CmnModelHelper cmnModelHelper
	
	@Inject
	protected CmnOpenApiGenerator openApiGenerator
	
	override void apply(CmnObject obj, Outlets osa) {
		val openApiOutlet = osa.get("generatedOpenApi")
		
		if (obj instanceof CmnModel) {
			obj.generateOpenApi(openApiOutlet)
		}
	}

	def void generateOpenApi(CmnModel model, Outlet openApiOutlet) {
		openApiGenerator.generateOpenApiYml(createGeneratorContext(model,openApiOutlet))
	}
	
	def OpenApiGeneratorContext createGeneratorContext(CmnModel model, Outlet outlet) {
		return new OpenApiGeneratorContext(model,outlet)
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy