Skip to content

Commit

Permalink
php generator option rrepository baseURL in readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
gracekarina committed Sep 17, 2021
1 parent 466f53b commit b35f10c
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class Generate implements Runnable {
protected String library;
protected String gitUserId;
protected String gitRepoId;
protected String gitRepoBaseURL;
protected String releaseNote;
protected String httpUserAgent;
protected List<String> reservedWordsMappings = new ArrayList<>();
Expand All @@ -81,6 +82,7 @@ public class Generate implements Runnable {
private String url;
private List<CodegenArgument> codegenArguments;


public void setVerbose(Boolean verbose) {
this.verbose = verbose;
}
Expand Down Expand Up @@ -189,6 +191,10 @@ public void setGitRepoId(String gitRepoId) {
this.gitRepoId = gitRepoId;
}

public void setGitRepoBaseURL(String gitRepoBaseURL) {
this.gitRepoBaseURL = gitRepoBaseURL;
}

public void setReleaseNote(String releaseNote) {
this.releaseNote = releaseNote;
}
Expand Down Expand Up @@ -324,6 +330,10 @@ public void run() {
configurator.setGitRepoId(gitRepoId);
}

if (isNotEmpty(gitRepoBaseURL)) {
configurator.setGitRepoBaseURL(gitRepoBaseURL);
}

if (isNotEmpty(releaseNote)) {
configurator.setReleaseNote(releaseNote);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/swagger-codegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
</reporting>
<properties>
<diffutils-version>1.3.0</diffutils-version>
<swagger-codegen-v2-version>2.4.21</swagger-codegen-v2-version>
<swagger-codegen-v2-version>2.4.22-SNAPSHOT</swagger-codegen-v2-version>
</properties>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ public interface CodegenConfig {

String getGitRepoId();

void setGitRepoBaseURL(String gitRepoBaseURL);

String getGitRepoBaseURL();

void setReleaseNote(String releaseNote);

String getReleaseNote();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case,
public static final String GIT_REPO_ID = "gitRepoId";
public static final String GIT_REPO_ID_DESC = "Git repo ID, e.g. swagger-codegen.";

public static final String GIT_REPO_BASE_URL = "gitRepoBaseURL";
public static final String GIT_REPO_BASE_URL_DESC = "Git repo Base URL, e.g. swagger-codegen.";

public static final String RELEASE_NOTE = "releaseNote";
public static final String RELEASE_NOTE_DESC = "Release note, default to 'Minor update'.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class CodegenConfigurator implements Serializable {

private String gitUserId="GIT_USER_ID";
private String gitRepoId="GIT_REPO_ID";
private String gitRepoBaseURL = "github";
private String releaseNote="Minor update";
private String httpUserAgent;

Expand Down Expand Up @@ -402,6 +403,16 @@ public CodegenConfigurator setGitRepoId(String gitRepoId) {
return this;
}

public String getGitRepoBaseURL() {
return gitRepoBaseURL;
}

public CodegenConfigurator setGitRepoBaseURL(String gitRepoBaseURL) {
this.gitRepoBaseURL = gitRepoBaseURL;
return this;
}


public String getReleaseNote() {
return releaseNote;
}
Expand Down Expand Up @@ -633,6 +644,7 @@ public ClientOptInput toClientOptInput() {
checkAndSetAdditionalProperty(modelNameSuffix, CodegenConstants.MODEL_NAME_SUFFIX);
checkAndSetAdditionalProperty(gitUserId, CodegenConstants.GIT_USER_ID);
checkAndSetAdditionalProperty(gitRepoId, CodegenConstants.GIT_REPO_ID);
checkAndSetAdditionalProperty(gitRepoBaseURL, CodegenConstants.GIT_REPO_BASE_URL);
checkAndSetAdditionalProperty(releaseNote, CodegenConstants.RELEASE_NOTE);
checkAndSetAdditionalProperty(httpUserAgent, CodegenConstants.HTTP_USER_AGENT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ public static io.swagger.codegen.ClientOptInput getClientOptInputV2(GenerationRe
if (isNotEmpty(options.getGitRepoId())) {
codegenConfig.additionalProperties().put(CodegenConstants.GIT_REPO_ID, options.getGitRepoId());
}
if (isNotEmpty(options.getGitRepoBaseURL())) {
codegenConfig.additionalProperties().put(CodegenConstants.GIT_REPO_BASE_URL, options.getGitRepoBaseURL());
}
if (isNotEmpty(options.getReleaseNote())) {
codegenConfig.additionalProperties().put(CodegenConstants.RELEASE_NOTE, options.getReleaseNote());
}
Expand Down Expand Up @@ -305,6 +308,9 @@ public static ClientOptInput getClientOptInput(GenerationRequest generationReque
if (isNotEmpty(options.getGitRepoId())) {
configurator.setGitRepoId(options.getGitRepoId());
}
if (isNotEmpty(options.getGitRepoBaseURL())) {
configurator.setGitRepoBaseURL(options.getGitRepoBaseURL());
}
if (isNotEmpty(options.getReleaseNote())) {
configurator.setReleaseNote(options.getReleaseNote());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class Options {
private String library;
private String gitUserId;
private String gitRepoId;
private String gitRepoBaseURL;
private String releaseNote;
private String httpUserAgent;
private Map<String, String> reservedWordsMappings = new LinkedHashMap<>();
Expand Down Expand Up @@ -366,6 +367,19 @@ public void setGitRepoId(String gitRepoId) {
this.gitRepoId = gitRepoId;
}

public Options gitRepoBaseURL(String gitRepoBaseURL) {
this.gitRepoBaseURL = gitRepoBaseURL;
return this;
}

public String getGitRepoBaseURL() {
return gitRepoBaseURL;
}

public void setGitRepoBaseURL(String gitRepoBaseURL) {
this.gitRepoBaseURL = gitRepoBaseURL;
}

public Options releaseNote(String releaseNote) {
this.releaseNote = releaseNote;
return this;
Expand Down Expand Up @@ -490,5 +504,4 @@ public Options flattenInlineComposedSchemas(boolean flattenInlineComposedSchemas
this.flattenInlineComposedSchemas = flattenInlineComposedSchemas;
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import java.util.List;

public class GeneratorServiceTest {



@Test(description = "test generator service with html2")
public void testGeneratorService_HTML2_Bearer() throws IOException {

Expand Down Expand Up @@ -50,7 +49,6 @@ public void testGeneratorService_HTML2_Bearer() throws IOException {
" -H \"Authorization: Bearer [[accessToken]]\"\\"));
}
}

}

@Test(description = "test generator service with html2")
Expand Down
114 changes: 114 additions & 0 deletions modules/swagger-codegen/src/test/resources/2_0/readme149.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
swagger: '2.0'
info:
description: This is a simple API
version: 1.0.0
title: Simple Inventory API
contact:
email: you@your-company.com
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
tags:
- name: admins
description: Secured Admin-only calls
- name: developers
description: Operations available to regular developers
paths:
/inventory:
get:
tags:
- developers
summary: searches inventory
operationId: searchInventory
description: |
By passing in the appropriate options, you can search for
available inventory in the system
produces:
- application/json
parameters:
- in: query
name: searchString
description: pass an optional search string for looking up inventory
required: false
type: string
- in: query
name: skip
description: number of records to skip for pagination
type: integer
format: int32
minimum: 0
- in: query
name: limit
description: maximum number of records to return
type: integer
format: int32
minimum: 0
maximum: 50
responses:
'200':
description: search results matching criteria
schema:
type: array
items:
$ref: '#/definitions/InventoryItem'
'400':
description: bad input parameter
post:
tags:
- admins
summary: adds an inventory item
operationId: addInventory
description: Adds an item to the system
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: inventoryItem
description: Inventory item to add
schema:
$ref: '#/definitions/InventoryItem'
responses:
'201':
description: item created
'400':
description: 'invalid input, object invalid'
'409':
description: an existing item already exists
definitions:
InventoryItem:
type: object
required:
- id
- name
- manufacturer
- releaseDate
properties:
id:
type: string
format: uuid
example: d290f1ee-6c54-4b01-90e6-d701748f0851
name:
type: string
example: Widget Adapter
releaseDate:
type: string
format: date-time
example: '2016-08-29T09:12:33.001Z'
manufacturer:
$ref: '#/definitions/Manufacturer'
Manufacturer:
required:
- name
properties:
name:
type: string
example: ACME Corporation
homePage:
type: string
format: url
example: 'https://www.acme-corp.com'
phone:
type: string
example: 408-867-5309
Loading

0 comments on commit b35f10c

Please sign in to comment.