Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

62 multiple servers is leading errors in client #63

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
17 changes: 10 additions & 7 deletions src/templates/angularClient.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ import { {{@key}} } from '../interfaces/{{@key}}.ts';
/**
{{description}}
*/
{{/if}}

{{/if}}
@Injectable({
providedIn: 'root'
})
export class {{tagname}}Service {
{{#servers}}
private server: string = '{{{url}}}';
{{/servers}}
private servers: string[] = [
{{#servers}}
'{{{url}}}',
{{/servers}}
]

private readonly headers: HttpHeaders = new HttpHeaders();

constructor(private http: HttpClient) {
Expand All @@ -26,10 +29,10 @@ export class {{tagname}}Service {

{{#paths}}
{{#methods}}
public {{operationId}}({{#parameters}}{{name}}: {{type}}, {{/parameters}}{{#with requestBody.content.[application/json]}}body: {{{getType this.type}}}{{/with}}){{#responses}}{{#with content.[application/json]}}: Observable<{{getType type}}>{{/with}}{{/responses}} {
public {{#if operationId}}{{{operationId}}}{{else}}{{methodName}}{{capitalize (removeSymbol ../route)}}{{/if}}({{#parameters}}{{name}}: {{type}}, {{/parameters}}{{#with requestBody.content.[application/json]}}body: {{{getType this.type}}}{{/with}}){{#responses}}{{#with content.[application/json]}}: Observable<{{getType type}}>{{/with}}{{/responses}} {
return this.http.{{methodName}}{{#responses}}{{#with content.[application/json]}}<{{getType type}}>{{/with}}{{/responses}}(`{{{../route}}}`{{#requestBody}}, body{{/requestBody}}{{#unless requestBody}}, null{{/unless}}, { headers: this.headers });
}

{{/methods}}
{{/paths}}
}
}
12 changes: 7 additions & 5 deletions src/templates/client.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ import {{@key}} from '../interfaces/{{@key}}.ts';
/**
{{description}}
*/
{{/if}}

{{/if}}
const SERVERS = [
{{#servers}}
const SERVER = '{{{url}}}'
'{{{url}}}',
{{/servers}}
]

{{#paths}}
{{#methods}}
export const {{{operationId}}} = async ({{#parameters}}{{name}}: {{getType type}}, {{/parameters}}{{#with requestBody.content.[application/json]}}body: {{{getType this.type}}}{{/with}}){{#responses}}{{#with content.[application/json]}}: {{getType type}}{{/with}}{{/responses}} => {
return await axios.{{methodName}}(`${SERVER}{{{../route}}}`{{#requestBody}}, body{{/requestBody}})
export const {{#if operationId}}{{{operationId}}}{{else}}{{methodName}}{{capitalize (removeSymbol ../route)}}{{/if}} = async ({{#parameters}}{{name}}: {{getType type}}, {{/parameters}}{{#with requestBody.content.[application/json]}}body: {{{getType this.type}}}{{/with}}) {{#responses}}{{#with content.[application/json]}}: Promise<{{getType type}}>{{/with}}{{/responses}} => {
return axios.{{methodName}}(`${SERVERS[0]}{{{../route}}}`{{#requestBody}}, body{{/requestBody}})
}
{{/methods}}

{{/paths}}
{{/paths}}
12 changes: 7 additions & 5 deletions src/templates/javascriptClient.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import axios from 'axios'
/**
{{description}}
*/
{{/if}}

{{/if}}
const SERVERS = [
{{#servers}}
const SERVER = '{{{url}}}';
'{{{url}}}',
{{/servers}}
]

{{#paths}}
{{#methods}}
export const {{{operationId}}} = async ({{#parameters}}{{name}},{{/parameters}}{{#with requestBody.content.[application/json]}}body{{/with}}) => {
return await axios.{{methodName}}(`${SERVER}{{{../route}}}`{{#requestBody}}, body{{/requestBody}})
export const {{#if operationId}}{{{operationId}}}{{else}}{{methodName}}{{capitalize (removeSymbol ../route)}}{{/if}} = async ({{#parameters}}{{name}},{{/parameters}}{{#with requestBody.content.[application/json]}}body{{/with}}) => {
return axios.{{methodName}}(`${SERVERS[0]}{{{../route}}}`{{#requestBody}}, body{{/requestBody}})
}
{{/methods}}

{{/paths}}
{{/paths}}
2 changes: 1 addition & 1 deletion src/templates/javascriptServer.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const express = require('express')
/**
{{description}}
*/
{{/if}}

{{/if}}
const app = express();

{{#paths}}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/server.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {{@key}} from '../interfaces/{{@key}}.ts';
/**
{{description}}
*/
{{/if}}

{{/if}}
const app = express();

{{#paths}}
Expand Down