UNPKG

@openapi-generator-plus/java-cxf-spring-server-generator

Version:
35 lines (34 loc) 1.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hooks = void 0; const template_utils_1 = require("@openapi-generator-plus/template-utils"); const pom_1 = require("./pom"); const apiTest_1 = require("./apiTest"); /** * Declares a Spring-injected dependency field, annotated with `@Autowired`. Callers embed * this behind their own single-tab indent (see `java-jaxrs-generator-common`'s single-line * default), so the field's own line bakes in that same indent after the annotation's newline. */ function inject(params) { var _a; const access = (_a = params.access) !== null && _a !== void 0 ? _a : 'private'; return `@org.springframework.beans.factory.annotation.Autowired\n\t${access} ${params.interface} ${params.name};`; } /** The API implementation class is named as a Spring bean, so a group's `Api` and `ApiService` implementations can coexist. */ function apiImplClassAnnotations(group, ctx) { const name = (0, template_utils_1.className)(ctx.generatorContext.generator(), group.name); return `@org.springframework.stereotype.Service("${name}Api")`; } /** * This generator's overrides of the DI, class-annotation and whole-file hooks from * `java-jaxrs-generator-common` and `java-jaxrs-server-generator`, wiring the generated * classes into Spring. */ exports.hooks = { inject, apiImplClassAnnotations, apiServiceImplClassAnnotations: () => '@org.springframework.stereotype.Service', jaxbJsonProviderAnnotations: () => '@org.springframework.stereotype.Service("ApiJaxbJsonProvider")', pom: pom_1.pom, apiTest: apiTest_1.apiTest, };