UNPKG

@nimbella/postman-api

Version:

Postman Collection to Nimbella Project: Take your APIs seamlessly into Serverless world with this API

51 lines (50 loc) 1.92 kB
"use strict"; /* * Copyright (c) 2019 - present Nimbella Corp. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const base_gen_1 = tslib_1.__importDefault(require("./base-gen")); const utils_1 = require("../../utils"); class JavaGenerator extends base_gen_1.default { constructor() { super('java'); } getMethodStub(item) { const path = item.request.url && item.request.url.path ? item.request.url.path.join('/') : ''; const namespace = utils_1.sanitizeName(item.name, ''); let [response] = item.responses.members; if (!response) { response = ''; } const code = response.code || 200; const headers = (response.headers || '').members; const cookies = (response.cookies || '').members; const { status } = response; const body = utils_1.escapeSpecialChars(JSON.stringify(response.body || '')); const description = (item.request.description || '').content; const params = { path, headers, status, code, cookies, body, description, namespace, }; return this.tmplMethod(Object.assign({}, params)); } } exports.default = JavaGenerator;