Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ const getPathVirtualProperty = (
) {
const _schema = current.schema;
const item: IDefinitionVirtualProperty = {
name: current.name,
name: camelCase(current.name),
originalName: current.name,
type: current.type ?? _schema?.type ?? "",
required: current.required,
description: current.description,
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ const parseParams = (parameters: IPathVirtualParameter, action: string) =>
if (!_multiParam) {
_formalParam = {
name: item.name,
originalName: item.originalName,
category: current,
type: _type,
description: (item.title || item.description) ?? "",
Expand Down Expand Up @@ -366,7 +367,7 @@ const getActionFiles = (data: Map<string, IPathVirtualProperty>) => {

Logs.info(`${getT("$t(plugin.parserAction)")}...`);
data.forEach((item, key) => {
const _tag = item.tag;
const _tag = item.tag?.replace(/\s+/g, "");

if (!_tag) {
Logs.error(getT("$t(plugin.no_tag)", { url: item.url }));
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/dart/template/actionMethod.eta
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Future<<%~ it.responseType %>> <%= it.methodName %>(<% it.params.forEach((param,
method: '<%= it.method %>'<% if (it.params.length) { %>,
params: {
<% it.params.forEach((param, index) => { %>
'<%= param.category %>': <% if (param.category === param.name) { %><%= param.name %><% } else { %>{'<%= param.name %>' : <%= param.name %>}<% } %><% if (index < it.params.length - 1) { %>, <% } %>
'<%= param.category %>': <% if (param.category === param.name) { %><%= param.name %><% } else { %>{'<%= param.originalName || param.name %>' : <%= param.name %>}<% } %><% if (index < it.params.length - 1) { %>, <% } %>

<% }) %>
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/dart/template/definitionFooter.eta
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
factory <%= it.defName %>.fromJson(Map<String, dynamic> json) {
return <%= it.defName %>(
<% it.props.forEach((prop, index) => { %>
<%= prop.name %>: json['<%= prop.name %>']<% if (index < it.props.length - 1) { %>,<% } %>
<%= prop.name %>: json['<%= prop.originalName || prop.name %>']<% if (index < it.props.length - 1) { %>,<% } %>

<% }) %>
);
Expand All @@ -18,7 +18,7 @@
final Map<String, dynamic> data = <String, dynamic>{};

<% it.props.forEach((prop) => { %>
data['<%= prop.name %>'] = <%= prop.name %>;
data['<%= prop.originalName || prop.name %>'] = <%= prop.name %>;
<% }) %>

return data;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/swift/template/actionMethod.eta
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public func <%= it.methodName %>(<% it.params.forEach((param, index) => { %>
<% if (pathParams.length > 0) { %>
let pathParams: [String: String] = [
<% pathParams.forEach((param, index) => { %>
"<%= param.name %>": String(<%= param.name %>)<% if (index < pathParams.length - 1) { %>,<% } %>
"<%= param.originalName || param.name %>": String(<%= param.name %>)<% if (index < pathParams.length - 1) { %>,<% } %>
<% }) %>
]
let parsedUrl = "<%= it.url %>".parsePathParams(pathParams)
Expand Down
9 changes: 8 additions & 1 deletion src/plugins/swift/template/definitionFooter.eta
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
}
<% if (it.props && it.props.some(prop => prop.originalName && prop.originalName !== prop.name)) { %>
private enum CodingKeys: String, CodingKey {
<% it.props.forEach(prop => { %>
case <%= prop.name %> = "<%= prop.originalName || prop.name %>"
<% }) %>
}
<% } %>
}
2 changes: 1 addition & 1 deletion src/plugins/typescript/template/actionMethod.eta
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const <%= it.methodName %> = (<% it.params.forEach((param, index) => { %>
<% it.params.forEach((param, index) => { %>
<%= param.category %><% if (param.category === param.name) { %>
<% } else { %>: <% if (param.category === 'body') { %><%= param.name %><% } else { %>{
<%= param.name %>
<%= param.originalName ? "'" + param.originalName + "': " + param.name : param.name %>

}<% } %>
<% } %><% if (index < it.params.length - 1) { %>, <% } %>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/typescript/template/definitionBody.eta
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

*/
<% } %>
<%= it.prop.name %><% if (!it.prop.required) { %>?<% } %>: <%~ it.propType %><% if (it.nullable) { %> | <%~ it.nullable %><% } %>;
"<%= it.prop.originalName || it.prop.name %>"<% if (!it.prop.required) { %>?<% } %>: <%~ it.propType %><% if (it.nullable) { %> | <%~ it.nullable %><% } %>;
1 change: 1 addition & 0 deletions src/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export interface IDefinitionVirtualProperty {
* 属性名
*/
name: string;
originalName?: string;
/**
* 属性类型。数组的情况,通常是 action 的返回值会多个
*/
Expand Down