Skip to content

Commit 2ca6acf

Browse files
committed
php generator option repository baseURL in readme file
1 parent 466f53b commit 2ca6acf

File tree

10 files changed

+279
-5
lines changed

10 files changed

+279
-5
lines changed

modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/v3/cli/cmd/Generate.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public class Generate implements Runnable {
6969
protected String library;
7070
protected String gitUserId;
7171
protected String gitRepoId;
72+
protected String gitRepoBaseURL;
7273
protected String releaseNote;
7374
protected String httpUserAgent;
7475
protected List<String> reservedWordsMappings = new ArrayList<>();
@@ -81,6 +82,7 @@ public class Generate implements Runnable {
8182
private String url;
8283
private List<CodegenArgument> codegenArguments;
8384

85+
8486
public void setVerbose(Boolean verbose) {
8587
this.verbose = verbose;
8688
}
@@ -189,6 +191,10 @@ public void setGitRepoId(String gitRepoId) {
189191
this.gitRepoId = gitRepoId;
190192
}
191193

194+
public void setGitRepoBaseURL(String gitRepoBaseURL) {
195+
this.gitRepoBaseURL = gitRepoBaseURL;
196+
}
197+
192198
public void setReleaseNote(String releaseNote) {
193199
this.releaseNote = releaseNote;
194200
}
@@ -324,6 +330,10 @@ public void run() {
324330
configurator.setGitRepoId(gitRepoId);
325331
}
326332

333+
if (isNotEmpty(gitRepoBaseURL)) {
334+
configurator.setGitRepoBaseURL(gitRepoBaseURL);
335+
}
336+
327337
if (isNotEmpty(releaseNote)) {
328338
configurator.setReleaseNote(releaseNote);
329339
}

modules/swagger-codegen/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
</reporting>
201201
<properties>
202202
<diffutils-version>1.3.0</diffutils-version>
203-
<swagger-codegen-v2-version>2.4.21</swagger-codegen-v2-version>
203+
<swagger-codegen-v2-version>2.4.22-SNAPSHOT</swagger-codegen-v2-version>
204204
</properties>
205205
<dependencies>
206206
<dependency>

modules/swagger-codegen/src/main/java/io/swagger/codegen/v3/CodegenConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ public interface CodegenConfig {
208208

209209
String getGitRepoId();
210210

211+
void setGitRepoBaseURL(String gitRepoBaseURL);
212+
213+
String getGitRepoBaseURL();
214+
211215
void setReleaseNote(String releaseNote);
212216

213217
String getReleaseNote();

modules/swagger-codegen/src/main/java/io/swagger/codegen/v3/CodegenConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case,
182182
public static final String GIT_REPO_ID = "gitRepoId";
183183
public static final String GIT_REPO_ID_DESC = "Git repo ID, e.g. swagger-codegen.";
184184

185+
public static final String GIT_REPO_BASE_URL = "gitRepoBaseURL";
186+
public static final String GIT_REPO_BASE_URL_DESC = "Git repo Base URL, e.g. swagger-codegen.";
187+
185188
public static final String RELEASE_NOTE = "releaseNote";
186189
public static final String RELEASE_NOTE_DESC = "Release note, default to 'Minor update'.";
187190

modules/swagger-codegen/src/main/java/io/swagger/codegen/v3/config/CodegenConfigurator.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public class CodegenConfigurator implements Serializable {
8787

8888
private String gitUserId="GIT_USER_ID";
8989
private String gitRepoId="GIT_REPO_ID";
90+
private String gitRepoBaseURL = "github";
9091
private String releaseNote="Minor update";
9192
private String httpUserAgent;
9293

@@ -402,6 +403,16 @@ public CodegenConfigurator setGitRepoId(String gitRepoId) {
402403
return this;
403404
}
404405

406+
public String getGitRepoBaseURL() {
407+
return gitRepoBaseURL;
408+
}
409+
410+
public CodegenConfigurator setGitRepoBaseURL(String gitRepoBaseURL) {
411+
this.gitRepoBaseURL = gitRepoBaseURL;
412+
return this;
413+
}
414+
415+
405416
public String getReleaseNote() {
406417
return releaseNote;
407418
}
@@ -633,6 +644,7 @@ public ClientOptInput toClientOptInput() {
633644
checkAndSetAdditionalProperty(modelNameSuffix, CodegenConstants.MODEL_NAME_SUFFIX);
634645
checkAndSetAdditionalProperty(gitUserId, CodegenConstants.GIT_USER_ID);
635646
checkAndSetAdditionalProperty(gitRepoId, CodegenConstants.GIT_REPO_ID);
647+
checkAndSetAdditionalProperty(gitRepoBaseURL, CodegenConstants.GIT_REPO_BASE_URL);
636648
checkAndSetAdditionalProperty(releaseNote, CodegenConstants.RELEASE_NOTE);
637649
checkAndSetAdditionalProperty(httpUserAgent, CodegenConstants.HTTP_USER_AGENT);
638650

modules/swagger-codegen/src/main/java/io/swagger/codegen/v3/service/GeneratorUtil.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ public static io.swagger.codegen.ClientOptInput getClientOptInputV2(GenerationRe
185185
if (isNotEmpty(options.getGitRepoId())) {
186186
codegenConfig.additionalProperties().put(CodegenConstants.GIT_REPO_ID, options.getGitRepoId());
187187
}
188+
if (isNotEmpty(options.getGitRepoBaseURL())) {
189+
codegenConfig.additionalProperties().put(CodegenConstants.GIT_REPO_BASE_URL, options.getGitRepoBaseURL());
190+
}
188191
if (isNotEmpty(options.getReleaseNote())) {
189192
codegenConfig.additionalProperties().put(CodegenConstants.RELEASE_NOTE, options.getReleaseNote());
190193
}
@@ -305,6 +308,9 @@ public static ClientOptInput getClientOptInput(GenerationRequest generationReque
305308
if (isNotEmpty(options.getGitRepoId())) {
306309
configurator.setGitRepoId(options.getGitRepoId());
307310
}
311+
if (isNotEmpty(options.getGitRepoBaseURL())) {
312+
configurator.setGitRepoBaseURL(options.getGitRepoBaseURL());
313+
}
308314
if (isNotEmpty(options.getReleaseNote())) {
309315
configurator.setReleaseNote(options.getReleaseNote());
310316
}

modules/swagger-codegen/src/main/java/io/swagger/codegen/v3/service/Options.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class Options {
2828
private String library;
2929
private String gitUserId;
3030
private String gitRepoId;
31+
private String gitRepoBaseURL;
3132
private String releaseNote;
3233
private String httpUserAgent;
3334
private Map<String, String> reservedWordsMappings = new LinkedHashMap<>();
@@ -366,6 +367,19 @@ public void setGitRepoId(String gitRepoId) {
366367
this.gitRepoId = gitRepoId;
367368
}
368369

370+
public Options gitRepoBaseURL(String gitRepoBaseURL) {
371+
this.gitRepoBaseURL = gitRepoBaseURL;
372+
return this;
373+
}
374+
375+
public String getGitRepoBaseURL() {
376+
return gitRepoBaseURL;
377+
}
378+
379+
public void setGitRepoBaseURL(String gitRepoBaseURL) {
380+
this.gitRepoBaseURL = gitRepoBaseURL;
381+
}
382+
369383
public Options releaseNote(String releaseNote) {
370384
this.releaseNote = releaseNote;
371385
return this;
@@ -490,5 +504,4 @@ public Options flattenInlineComposedSchemas(boolean flattenInlineComposedSchemas
490504
this.flattenInlineComposedSchemas = flattenInlineComposedSchemas;
491505
return this;
492506
}
493-
494507
}

modules/swagger-codegen/src/test/java/io/swagger/codegen/v3/service/GeneratorServiceTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
import java.util.List;
1919

2020
public class GeneratorServiceTest {
21-
22-
21+
2322
@Test(description = "test generator service with html2")
2423
public void testGeneratorService_HTML2_Bearer() throws IOException {
2524

@@ -50,7 +49,6 @@ public void testGeneratorService_HTML2_Bearer() throws IOException {
5049
" -H \"Authorization: Bearer [[accessToken]]\"\\"));
5150
}
5251
}
53-
5452
}
5553

5654
@Test(description = "test generator service with html2")
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
swagger: '2.0'
2+
info:
3+
description: This is a simple API
4+
version: 1.0.0
5+
title: Simple Inventory API
6+
contact:
7+
8+
license:
9+
name: Apache 2.0
10+
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
11+
tags:
12+
- name: admins
13+
description: Secured Admin-only calls
14+
- name: developers
15+
description: Operations available to regular developers
16+
paths:
17+
/inventory:
18+
get:
19+
tags:
20+
- developers
21+
summary: searches inventory
22+
operationId: searchInventory
23+
description: |
24+
By passing in the appropriate options, you can search for
25+
available inventory in the system
26+
produces:
27+
- application/json
28+
parameters:
29+
- in: query
30+
name: searchString
31+
description: pass an optional search string for looking up inventory
32+
required: false
33+
type: string
34+
- in: query
35+
name: skip
36+
description: number of records to skip for pagination
37+
type: integer
38+
format: int32
39+
minimum: 0
40+
- in: query
41+
name: limit
42+
description: maximum number of records to return
43+
type: integer
44+
format: int32
45+
minimum: 0
46+
maximum: 50
47+
responses:
48+
'200':
49+
description: search results matching criteria
50+
schema:
51+
type: array
52+
items:
53+
$ref: '#/definitions/InventoryItem'
54+
'400':
55+
description: bad input parameter
56+
post:
57+
tags:
58+
- admins
59+
summary: adds an inventory item
60+
operationId: addInventory
61+
description: Adds an item to the system
62+
consumes:
63+
- application/json
64+
produces:
65+
- application/json
66+
parameters:
67+
- in: body
68+
name: inventoryItem
69+
description: Inventory item to add
70+
schema:
71+
$ref: '#/definitions/InventoryItem'
72+
responses:
73+
'201':
74+
description: item created
75+
'400':
76+
description: 'invalid input, object invalid'
77+
'409':
78+
description: an existing item already exists
79+
definitions:
80+
InventoryItem:
81+
type: object
82+
required:
83+
- id
84+
- name
85+
- manufacturer
86+
- releaseDate
87+
properties:
88+
id:
89+
type: string
90+
format: uuid
91+
example: d290f1ee-6c54-4b01-90e6-d701748f0851
92+
name:
93+
type: string
94+
example: Widget Adapter
95+
releaseDate:
96+
type: string
97+
format: date-time
98+
example: '2016-08-29T09:12:33.001Z'
99+
manufacturer:
100+
$ref: '#/definitions/Manufacturer'
101+
Manufacturer:
102+
required:
103+
- name
104+
properties:
105+
name:
106+
type: string
107+
example: ACME Corporation
108+
homePage:
109+
type: string
110+
format: url
111+
example: 'https://www.acme-corp.com'
112+
phone:
113+
type: string
114+
example: 408-867-5309

0 commit comments

Comments
 (0)