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

PHP - Permit to customize more composer.json parts #16012

Merged
merged 1 commit into from
Jul 12, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ public class CodegenConstants {
public static final String PACKAGE_COMPANY_DESC = "Specifies an AssemblyCompany for the .NET Framework global assembly attributes stored in the AssemblyInfo file.";
public static final String PACKAGE_AUTHORS = "packageAuthors";
public static final String PACKAGE_AUTHORS_DESC = "Specifies Authors property in the .NET Core project file.";
public static final String PACKAGE_AUTHORS_URL = "packageAuthorsUrl";
public static final String PACKAGE_AUTHORS_URL_DESC = "Specifies Authors URL property in the PHP composer.json file.";
public static final String PACKAGE_COPYRIGHT = "packageCopyright";
public static final String PACKAGE_COPYRIGHT_DESC = "Specifies an AssemblyCopyright for the .NET Framework global assembly attributes stored in the AssemblyInfo file.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
protected String invokerPackage = "php";
protected String packageName = "php-base";
protected String artifactVersion = null;
protected String artifactUrl = "https://openapi-generator.tech";
protected String licenseName = "unlicense";
protected String developerOrganization = "OpenAPI";
protected String developerOrganizationUrl = "https://openapi-generator.tech";
protected String srcBasePath = "lib";
protected String testBasePath = "test";
protected String docsBasePath = "docs";
Expand Down Expand Up @@ -147,6 +151,10 @@ public AbstractPhpCodegen() {
cliOptions.add(new CliOption(PACKAGE_NAME, "The main package name for classes. e.g. GeneratedPetstore"));
cliOptions.add(new CliOption(SRC_BASE_PATH, "The directory to serve as source root."));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "The version to use in the composer package version field. e.g. 1.2.3"));
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_URL, CodegenConstants.ARTIFACT_URL_DESC));
cliOptions.add(new CliOption(CodegenConstants.LICENSE_NAME, CodegenConstants.LICENSE_NAME_DESC));
cliOptions.add(new CliOption(CodegenConstants.DEVELOPER_ORGANIZATION, CodegenConstants.DEVELOPER_ORGANIZATION_DESC));
cliOptions.add(new CliOption(CodegenConstants.DEVELOPER_ORGANIZATION_URL, CodegenConstants.DEVELOPER_ORGANIZATION_URL_DESC));
}

@Override
Expand Down Expand Up @@ -192,12 +200,41 @@ public void processOpts() {
}
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);

// {{artifactVersion}}
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) {
this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION));
} else {
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
}

// {{artifactUrl}}
if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_URL)) {
this.setArtifactUrl((String) additionalProperties.get(CodegenConstants.ARTIFACT_URL));
} else {
additionalProperties.put(CodegenConstants.ARTIFACT_URL, artifactUrl);
}

// {{licenseName}}
if (additionalProperties.containsKey(CodegenConstants.LICENSE_NAME)) {
this.setLicenseName((String) additionalProperties.get(CodegenConstants.LICENSE_NAME));
} else {
additionalProperties.put(CodegenConstants.LICENSE_NAME, licenseName);
}

// {{developerOrganization}}
if (additionalProperties.containsKey(CodegenConstants.DEVELOPER_ORGANIZATION)) {
this.setDeveloperOrganization((String) additionalProperties.get(CodegenConstants.DEVELOPER_ORGANIZATION));
} else {
additionalProperties.put(CodegenConstants.DEVELOPER_ORGANIZATION, developerOrganization);
}

// {{developerOrganizationUrl}}
if (additionalProperties.containsKey(CodegenConstants.DEVELOPER_ORGANIZATION_URL)) {
this.setDeveloperOrganizationUrl((String) additionalProperties.get(CodegenConstants.DEVELOPER_ORGANIZATION_URL));
} else {
additionalProperties.put(CodegenConstants.DEVELOPER_ORGANIZATION_URL, developerOrganizationUrl);
}

if (additionalProperties.containsKey(VARIABLE_NAMING_CONVENTION)) {
this.setParameterNamingConvention((String) additionalProperties.get(VARIABLE_NAMING_CONVENTION));
}
Expand Down Expand Up @@ -380,10 +417,6 @@ public String getSchemaType(Schema p) {
return toModelName(type);
}

public String getInvokerPackage() {
return invokerPackage;
}

wing328 marked this conversation as resolved.
Show resolved Hide resolved
public void setInvokerPackage(String invokerPackage) {
this.invokerPackage = invokerPackage;
}
Expand All @@ -392,6 +425,22 @@ public void setArtifactVersion(String artifactVersion) {
this.artifactVersion = artifactVersion;
}

public void setArtifactUrl(String artifactUrl) {
this.artifactUrl = artifactUrl;
}

public void setLicenseName(String licenseName) {
this.licenseName = licenseName;
}

public void setDeveloperOrganization(String developerOrganization) {
this.developerOrganization = developerOrganization;
}

public void setDeveloperOrganizationUrl(String developerOrganizationUrl) {
this.developerOrganizationUrl = developerOrganizationUrl;
}

public void setPackageName(String packageName) {
this.packageName = packageName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"rest",
"api"
],
"homepage": "https://openapi-generator.tech",
"license": "unlicense",
"homepage": "{{artifactUrl}}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use {{{ ... }}} instead of {{ ... }}, which outputs HTML escaped value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will take care of it after merging this PR into master

"license": "{{licenseName}}",
"authors": [
{
"name": "OpenAPI-Generator contributors",
"homepage": "https://openapi-generator.tech"
"name": "{{developerOrganization}}",
"homepage": "{{developerOrganizationUrl}}"
}
],
"require": {
Expand Down