Skip to content

Commit

Permalink
Release 4.0.2 (#112)
Browse files Browse the repository at this point in the history
* docs: update CHANGELOG

* fix: replaced all new syntax sugar like '?.' or '??' to prev. alternatives for support nodejs 12

* bump: up version to 4.0.2
  • Loading branch information
js2me authored Jan 12, 2021
1 parent c478151 commit a2a5fb7
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# next release

# 4.0.2

Fixes:
- `Unexpected token '.'` on v4 (Thanks @savingprivatebryan for issue #111)
Replaced all new syntax sugar like `?.` or `??` to prev. alternatives for support nodejs 12

# 4.0.1

Fixes:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swagger-typescript-api",
"version": "4.0.1",
"version": "4.0.2",
"description": "Create typescript api module from swagger schema",
"scripts": {
"cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts --extract-request-params --enum-names-as-values",
Expand Down
2 changes: 1 addition & 1 deletion src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ const parseRoutes = ({ usageSchema, parsedSchemas, moduleNameIndex, extractReque
const jsDocDescription =
description && ` * @description ${formatDescription(description, true)}`;
const jsDocLines = _.compact([
tags?.length && ` * @tags ${tags.join(", ")}`,
_.size(tags) && ` * @tags ${tags.join(", ")}`,
` * @name ${routeId}`,
summary && ` * @summary ${summary}`,
` * @request ${_.upperCase(method)}:${route}`,
Expand Down
4 changes: 2 additions & 2 deletions templates/default/procedure-call.eta
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { _, getInlineParseContent, getParseContent, parseSchema, getComponentByRe
const { parameters, path, method, payload, params, query, formData, security, requestParams } = route.request;
const { type, errorType } = route.response;
const routeDocs = includeFile("./route-docs", { config, route, utils });
const queryName = query?.name ?? "query";
const queryName = (query && query.name) || "query";
const pathParams = _.values(parameters);

const argToTmpl = ({ name, optional, type }) => `${name}${optional ? '?' : ''}: ${type}`;
Expand Down Expand Up @@ -42,7 +42,7 @@ const securityTmpl = security ? 'true' : null
const pathTmpl = query != null
? `\`${path}\${this.addQueryParams(${queryName})}\``
: `\`${path}\``
const requestArgs = [pathTmpl, `'${_.upperCase(method)}'`, params?.name, payload?.name, bodyModeTmpl, securityTmpl]
const requestArgs = [pathTmpl, `'${_.upperCase(method)}'`, _.get(params, "name"), _.get(payload, "name"), bodyModeTmpl, securityTmpl]
.reverse()
.reduce((args, arg) => {
if (args.length === 0 && !arg) return args
Expand Down
2 changes: 1 addition & 1 deletion templates/default/route-docs.eta
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const jsDocDescription = raw.description ?
` * @description ${formatDescription(raw.description, true)}` :
fmtToJSDocLine('No description', { eol: false });
const jsDocLines = _.compact([
raw.tags?.length && ` * @tags ${raw.tags.join(", ")}`,
_.size(raw.tags) && ` * @tags ${raw.tags.join(", ")}`,
` * @name ${classNameCase(routeName.usage)}`,
raw.summary && ` * @summary ${raw.summary}`,
` * @request ${_.upperCase(request.method)}:${raw.route}`,
Expand Down
6 changes: 3 additions & 3 deletions templates/default/route-type.eta
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const { query, payload } = route.request
const { type: responseType } = route.response

const routeDocs = includeFile("./route-docs", { config, route, utils });
const routeNamespace = classNameCase(route.routeName.usage)
const queryType = query?.type || '{}'
const bodyType = payload?.type || 'never'
const routeNamespace = classNameCase(route.routeName.usage);
const queryType = (query && query.type) || '{}';
const bodyType = (payload && payload.type) || 'never';
%>
/**
<%~ routeDocs.description %>
Expand Down
4 changes: 2 additions & 2 deletions templates/modular/procedure-call.eta
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { _, getInlineParseContent, getParseContent, parseSchema, getComponentByRe
const { parameters, path, method, payload, params, query, formData, security, requestParams } = route.request;
const { type, errorType } = route.response;
const routeDocs = includeFile("./route-docs", { config, route, utils });
const queryName = query?.name ?? "query";
const queryName = (query && query.name) || "query";
const pathParams = _.values(parameters);

const argToTmpl = ({ name, optional, type }) => `${name}${optional ? '?' : ''}: ${type}`;
Expand Down Expand Up @@ -42,7 +42,7 @@ const securityTmpl = security ? 'true' : null
const pathTmpl = query != null
? '`' + path + '${this.addQueryParams(' + query.name + ')}' + '`'
: '`' + path + '`'
const requestArgs = [pathTmpl, `'${_.upperCase(method)}'`, params?.name ?? null, payload?.name ?? null, bodyModeTmpl, securityTmpl]
const requestArgs = [pathTmpl, `'${_.upperCase(method)}'`, _.get(params, "name"), _.get(payload, "name"), bodyModeTmpl, securityTmpl]
.reverse()
.reduce((args, arg) => {
if (args.length === 0 && !arg) return args
Expand Down
2 changes: 1 addition & 1 deletion templates/modular/route-docs.eta
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const jsDocDescription = raw.description ?
` * @description ${formatDescription(raw.description, true)}` :
fmtToJSDocLine('No description', { eol: false });
const jsDocLines = _.compact([
raw.tags?.length && ` * @tags ${raw.tags.join(", ")}`,
_.size(raw.tags) && ` * @tags ${raw.tags.join(", ")}`,
` * @name ${classNameCase(routeName.usage)}`,
raw.summary && ` * @summary ${raw.summary}`,
` * @request ${_.upperCase(request.method)}:${raw.route}`,
Expand Down
4 changes: 2 additions & 2 deletions templates/modular/route-type.eta
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const { type: responseType } = route.response;

const routeDocs = includeFile("./route-docs", { config, route, utils });
const routeNamespace = classNameCase(routeName.usage);
const queryType = query?.type || '{}';
const bodyType = payload?.type || 'never';
const queryType = (query && query.type) || '{}';
const bodyType = (payload && payload.type) || 'never';
%>
/**
<%~ routeDocs.description %>
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/templates/spec_templates/procedure-call.eta
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const securityTmpl = security ? 'true' : null
const pathTmpl = query != null
? '`' + path + '${this.addQueryParams(' + query.name + ')}' + '`'
: '`' + path + '`'
const requestArgs = [pathTmpl, `'${_.upperCase(method)}'`, params?.name ?? null, payload?.name ?? null, bodyModeTmpl, securityTmpl]
const requestArgs = [pathTmpl, `'${_.upperCase(method)}'`, _.get(params, "name"), _.get(payload, "name"), bodyModeTmpl, securityTmpl]
.reverse()
.reduce((args, arg) => {
if (args.length === 0 && !arg) return args
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/templates/spec_templates/route-docs.eta
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const jsDocDescription = raw.description ?
` * @description ${formatDescription(raw.description, true)}` :
fmtToJSDocLine('No description', { eol: false });
const jsDocLines = _.compact([
raw.tags?.length && ` * @tags ${raw.tags.join(", ")}`,
_.size(raw.tags) && ` * @tags ${raw.tags.join(", ")}`,
` * @name ${classNameCase(routeName.usage)}`,
raw.summary && ` * @summary ${raw.summary}`,
` * @request ${_.upperCase(request.method)}:${raw.route}`,
Expand Down
4 changes: 2 additions & 2 deletions tests/spec/templates/spec_templates/route-type.eta
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const { type: responseType } = route.response

const routeDocs = includeFile("./route-docs", { config, route, utils });
const routeNamespace = classNameCase(route.routeName.usage)
const queryType = query?.type || '{}'
const bodyType = payload?.type || 'never'
const queryType = (query && query.type) || '{}'
const bodyType = (payload && payload.type) || 'never'
%>
/**
<%~ routeDocs.description %>
Expand Down

0 comments on commit a2a5fb7

Please sign in to comment.