diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml index 16a3f37..d509539 100644 --- a/.github/workflows/broken-links.yml +++ b/.github/workflows/broken-links.yml @@ -19,7 +19,7 @@ jobs: - name: Link Checker id: lychee - uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332 # v2 + uses: lycheeverse/lychee-action@5c4ee84814c983aa7164eaee476f014e53ff3963 # v2 with: fail: false # Don't fail on broken links, create an issue instead @@ -31,13 +31,13 @@ jobs: GH_TOKEN: ${{ github.token }} - name: Close issue if everything is fine - if: env.lychee_exit_code == 0 && steps.find-issue.outputs.number != '' + if: steps.lychee.outputs.exit_code == 0 && steps.find-issue.outputs.number != '' run: gh issue close -r 'not planned' ${{ steps.find-issue.outputs.number }} env: GH_TOKEN: ${{ github.token }} - name: Create Issue From File - if: env.lychee_exit_code != 0 + if: steps.lychee.outputs.exit_code != 0 uses: peter-evans/create-issue-from-file@e8ef132d6df98ed982188e460ebb3b5d4ef3a9cd # v5 with: issue-number: ${{ steps.find-issue.outputs.number }} diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml index 01edc3a..65e1e41 100644 --- a/.github/workflows/check-build.yml +++ b/.github/workflows/check-build.yml @@ -20,7 +20,6 @@ on: - 'assets/**' env: - PRIMARY_MAVEN_MODULE: ${{ github.event.repository.name }} DEMO_MAVEN_MODULE: ${{ github.event.repository.name }}-demo jobs: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 210ef8c..5f8fb83 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -104,9 +104,6 @@ jobs: runs-on: ubuntu-latest needs: [prepare-release] timeout-minutes: 60 - permissions: - contents: read - packages: write steps: - uses: actions/checkout@v4 @@ -121,15 +118,17 @@ jobs: with: # running setup-java overwrites the settings.xml distribution: 'temurin' java-version: '17' + server-id: github-central + server-password: PACKAGES_CENTRAL_TOKEN gpg-passphrase: MAVEN_GPG_PASSPHRASE gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Only import once - - name: Publish to Central Portal - run: ../mvnw -B deploy -P publish -DskipTests -DaltDeploymentRepository=github::https://maven.pkg.github.com/${{ github.repository }} + - name: Publish to GitHub Packages Central + run: ../mvnw -B deploy -P publish -DskipTests -DaltDeploymentRepository=github-central::https://maven.pkg.github.com/xdev-software/central + working-directory: ${{ env.PRIMARY_MAVEN_MODULE }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PACKAGES_CENTRAL_TOKEN: ${{ secrets.PACKAGES_CENTRAL_TOKEN }} MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} - working-directory: ${{ env.PRIMARY_MAVEN_MODULE }} - name: Set up JDK uses: actions/setup-java@v4 diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml index 922eda0..046be63 100644 --- a/.github/workflows/test-deploy.yml +++ b/.github/workflows/test-deploy.yml @@ -10,9 +10,6 @@ jobs: publish-maven: runs-on: ubuntu-latest timeout-minutes: 60 - permissions: - contents: read - packages: write steps: - uses: actions/checkout@v4 @@ -21,14 +18,16 @@ jobs: with: # running setup-java overwrites the settings.xml distribution: 'temurin' java-version: '17' + server-id: github-central + server-password: PACKAGES_CENTRAL_TOKEN gpg-passphrase: MAVEN_GPG_PASSPHRASE gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Only import once - - name: Publish to GitHub Packages - run: ../mvnw -B deploy -P publish -DskipTests -DaltDeploymentRepository=github::https://maven.pkg.github.com/${{ github.repository }} + - name: Publish to GitHub Packages Central + run: ../mvnw -B deploy -P publish -DskipTests -DaltDeploymentRepository=github-central::https://maven.pkg.github.com/xdev-software/central working-directory: ${{ env.PRIMARY_MAVEN_MODULE }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PACKAGES_CENTRAL_TOKEN: ${{ secrets.PACKAGES_CENTRAL_TOKEN }} MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} - name: Set up JDK diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml index b52c3e2..d43641c 100644 --- a/.idea/checkstyle-idea.xml +++ b/.idea/checkstyle-idea.xml @@ -1,7 +1,7 @@ - 10.21.0 + 10.26.1 JavaOnlyWithTests true true diff --git a/CHANGELOG.md b/CHANGELOG.md index 20d1103..b85bf27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.1.1 +* Fixed some incorrectly generated classes for ``additionalProperties: oneOf: ...`` #181 + # 1.1.0 * Updated generated code from Brevo's openapi.yml * Updated references to "new" official Brevo client # diff --git a/brevo-java-client-demo/src/main/java/software/xdev/Application.java b/brevo-java-client-demo/src/main/java/software/xdev/Application.java index 5554bc9..f6a3de6 100644 --- a/brevo-java-client-demo/src/main/java/software/xdev/Application.java +++ b/brevo-java-client-demo/src/main/java/software/xdev/Application.java @@ -9,6 +9,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import software.xdev.brevo.IdentifierType; import software.xdev.brevo.api.ContactsApi; import software.xdev.brevo.client.ApiClient; import software.xdev.brevo.client.ApiException; @@ -42,7 +43,7 @@ public static void main(final String[] args) new GetContactInfoIdentifierStringParameter(email); final GetExtendedContactDetails contactInfo = contactsApi.getContactInfo( identifier, - null, + IdentifierType.EMAIL, null, null); LOG.info("Got contact[email={},listIds={}]", contactInfo.getEmail(), contactInfo.getListIds()); @@ -51,7 +52,7 @@ public static void main(final String[] args) contactsApi.updateContact( identifier, new UpdateContact().listIds(List.of(listId)), - null); + IdentifierType.EMAIL); LOG.info("Updated contact to include listId={}", listId); } } diff --git a/brevo-java-client/pom.xml b/brevo-java-client/pom.xml index 8b9db04..37231de 100644 --- a/brevo-java-client/pom.xml +++ b/brevo-java-client/pom.xml @@ -61,7 +61,7 @@ com.fasterxml.jackson jackson-bom - 2.19.1 + 2.19.2 pom import @@ -223,7 +223,7 @@ org.codehaus.mojo flatten-maven-plugin - 1.7.1 + 1.7.2 ossrh @@ -449,7 +449,7 @@ com.puppycrawl.tools checkstyle - 10.26.1 + 11.0.0 @@ -490,12 +490,12 @@ net.sourceforge.pmd pmd-core - 7.15.0 + 7.16.0 net.sourceforge.pmd pmd-java - 7.15.0 + 7.16.0 diff --git a/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateContact.java b/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateContact.java index 3aa668b..2fa5b7b 100644 --- a/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateContact.java +++ b/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateContact.java @@ -25,7 +25,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import software.xdev.brevo.model.CreateDoiContactAttributesValue; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; import java.io.UnsupportedEncodingException; @@ -57,7 +56,7 @@ public class CreateContact { public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; @jakarta.annotation.Nullable - private Map attributes = new HashMap<>(); + private Map attributes = new HashMap<>(); public static final String JSON_PROPERTY_EMAIL_BLACKLISTED = "emailBlacklisted"; @jakarta.annotation.Nullable @@ -132,13 +131,13 @@ public void setExtId(@jakarta.annotation.Nullable String extId) { this.extId = extId; } - public CreateContact attributes(@jakarta.annotation.Nullable Map attributes) { + public CreateContact attributes(@jakarta.annotation.Nullable Map attributes) { this.attributes = attributes; return this; } - public CreateContact putAttributesItem(String key, CreateDoiContactAttributesValue attributesItem) { + public CreateContact putAttributesItem(String key, Object attributesItem) { if (this.attributes == null) { this.attributes = new HashMap<>(); } @@ -152,16 +151,16 @@ public CreateContact putAttributesItem(String key, CreateDoiContactAttributesVal */ @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_ATTRIBUTES) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS) - public Map getAttributes() { + public Map getAttributes() { return attributes; } @JsonProperty(JSON_PROPERTY_ATTRIBUTES) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setAttributes(@jakarta.annotation.Nullable Map attributes) { + @JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS) + public void setAttributes(@jakarta.annotation.Nullable Map attributes) { this.attributes = attributes; } @@ -412,9 +411,13 @@ public String toUrlQueryString(String prefix) { // add `attributes` to the URL query string if (getAttributes() != null) { for (String _key : getAttributes().keySet()) { - if (getAttributes().get(_key) != null) { - joiner.add(getAttributes().get(_key).toUrlQueryString(String.format("%sattributes%s%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix)))); + try { + joiner.add(String.format("%sattributes%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getAttributes().get(_key), URLEncoder.encode(String.valueOf(getAttributes().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); } } } diff --git a/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateDoiContact.java b/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateDoiContact.java index 0085a60..7e7ad58 100644 --- a/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateDoiContact.java +++ b/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateDoiContact.java @@ -25,7 +25,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import software.xdev.brevo.model.CreateDoiContactAttributesValue; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; import java.io.UnsupportedEncodingException; @@ -51,7 +50,7 @@ public class CreateDoiContact { public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; @jakarta.annotation.Nullable - private Map attributes = new HashMap<>(); + private Map attributes = new HashMap<>(); public static final String JSON_PROPERTY_INCLUDE_LIST_IDS = "includeListIds"; @jakarta.annotation.Nonnull @@ -97,13 +96,13 @@ public void setEmail(@jakarta.annotation.Nonnull String email) { this.email = email; } - public CreateDoiContact attributes(@jakarta.annotation.Nullable Map attributes) { + public CreateDoiContact attributes(@jakarta.annotation.Nullable Map attributes) { this.attributes = attributes; return this; } - public CreateDoiContact putAttributesItem(String key, CreateDoiContactAttributesValue attributesItem) { + public CreateDoiContact putAttributesItem(String key, Object attributesItem) { if (this.attributes == null) { this.attributes = new HashMap<>(); } @@ -117,16 +116,16 @@ public CreateDoiContact putAttributesItem(String key, CreateDoiContactAttributes */ @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_ATTRIBUTES) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS) - public Map getAttributes() { + public Map getAttributes() { return attributes; } @JsonProperty(JSON_PROPERTY_ATTRIBUTES) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setAttributes(@jakarta.annotation.Nullable Map attributes) { + @JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS) + public void setAttributes(@jakarta.annotation.Nullable Map attributes) { this.attributes = attributes; } @@ -338,9 +337,13 @@ public String toUrlQueryString(String prefix) { // add `attributes` to the URL query string if (getAttributes() != null) { for (String _key : getAttributes().keySet()) { - if (getAttributes().get(_key) != null) { - joiner.add(getAttributes().get(_key).toUrlQueryString(String.format("%sattributes%s%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix)))); + try { + joiner.add(String.format("%sattributes%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getAttributes().get(_key), URLEncoder.encode(String.valueOf(getAttributes().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); } } } diff --git a/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateDoiContactAttributesValue.java b/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateDoiContactAttributesValue.java deleted file mode 100644 index f27ec95..0000000 --- a/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateDoiContactAttributesValue.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Brevo API - * Brevo API documentation by XDEV Software based on https://api.brevo.com/v3/swagger_definition_v3.yml - * - * The version of the OpenAPI document: 3.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package software.xdev.brevo.model; - -import java.util.Objects; -import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonTypeName; -import java.math.BigDecimal; -import java.util.List; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.StringJoiner; - -/** - * CreateDoiContactAttributesValue - */ -@JsonPropertyOrder({ -}) -@JsonTypeName("createDoiContact_attributes_value") -public class CreateDoiContactAttributesValue { - public CreateDoiContactAttributesValue() { - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class CreateDoiContactAttributesValue {\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Convert the instance into URL query string. - * - * @return URL query string - */ - public String toUrlQueryString() { - return toUrlQueryString(null); - } - - /** - * Convert the instance into URL query string. - * - * @param prefix prefix of the query string - * @return URL query string - */ - public String toUrlQueryString(String prefix) { - String suffix = ""; - String containerSuffix = ""; - String containerPrefix = ""; - if (prefix == null) { - // style=form, explode=true, e.g. /pet?name=cat&type=manx - prefix = ""; - } else { - // deepObject style e.g. /pet?id[name]=cat&id[type]=manx - prefix = prefix + "["; - suffix = "]"; - containerSuffix = "]"; - containerPrefix = "["; - } - - StringJoiner joiner = new StringJoiner("&"); - - return joiner.toString(); - } - -} - diff --git a/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateUpdateProduct.java b/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateUpdateProduct.java index 82e97e6..bfea8af 100644 --- a/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateUpdateProduct.java +++ b/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateUpdateProduct.java @@ -26,7 +26,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import software.xdev.brevo.model.GetContactInfoIdentifierParameter; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; import java.io.UnsupportedEncodingException; @@ -87,7 +86,7 @@ public class CreateUpdateProduct { public static final String JSON_PROPERTY_META_INFO = "metaInfo"; @jakarta.annotation.Nullable - private Map metaInfo = new HashMap<>(); + private Map metaInfo = new HashMap<>(); public static final String JSON_PROPERTY_UPDATE_ENABLED = "updateEnabled"; @jakarta.annotation.Nullable @@ -316,13 +315,13 @@ public void setParentId(@jakarta.annotation.Nullable String parentId) { this.parentId = parentId; } - public CreateUpdateProduct metaInfo(@jakarta.annotation.Nullable Map metaInfo) { + public CreateUpdateProduct metaInfo(@jakarta.annotation.Nullable Map metaInfo) { this.metaInfo = metaInfo; return this; } - public CreateUpdateProduct putMetaInfoItem(String key, GetContactInfoIdentifierParameter metaInfoItem) { + public CreateUpdateProduct putMetaInfoItem(String key, Object metaInfoItem) { if (this.metaInfo == null) { this.metaInfo = new HashMap<>(); } @@ -336,16 +335,16 @@ public CreateUpdateProduct putMetaInfoItem(String key, GetContactInfoIdentifierP */ @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_META_INFO) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS) - public Map getMetaInfo() { + public Map getMetaInfo() { return metaInfo; } @JsonProperty(JSON_PROPERTY_META_INFO) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setMetaInfo(@jakarta.annotation.Nullable Map metaInfo) { + @JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS) + public void setMetaInfo(@jakarta.annotation.Nullable Map metaInfo) { this.metaInfo = metaInfo; } @@ -629,9 +628,13 @@ public String toUrlQueryString(String prefix) { // add `metaInfo` to the URL query string if (getMetaInfo() != null) { for (String _key : getMetaInfo().keySet()) { - if (getMetaInfo().get(_key) != null) { - joiner.add(getMetaInfo().get(_key).toUrlQueryString(String.format("%smetaInfo%s%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix)))); + try { + joiner.add(String.format("%smetaInfo%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMetaInfo().get(_key), URLEncoder.encode(String.valueOf(getMetaInfo().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); } } } diff --git a/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateUpdateProducts.java b/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateUpdateProducts.java index d36d481..49a4663 100644 --- a/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateUpdateProducts.java +++ b/brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateUpdateProducts.java @@ -26,7 +26,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import software.xdev.brevo.model.GetContactInfoIdentifierParameter; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; import java.io.UnsupportedEncodingException; @@ -86,7 +85,7 @@ public class CreateUpdateProducts { public static final String JSON_PROPERTY_META_INFO = "metaInfo"; @jakarta.annotation.Nullable - private Map metaInfo = new HashMap<>(); + private Map metaInfo = new HashMap<>(); public static final String JSON_PROPERTY_DELETED_AT = "deletedAt"; @jakarta.annotation.Nullable @@ -311,13 +310,13 @@ public void setParentId(@jakarta.annotation.Nullable String parentId) { this.parentId = parentId; } - public CreateUpdateProducts metaInfo(@jakarta.annotation.Nullable Map metaInfo) { + public CreateUpdateProducts metaInfo(@jakarta.annotation.Nullable Map metaInfo) { this.metaInfo = metaInfo; return this; } - public CreateUpdateProducts putMetaInfoItem(String key, GetContactInfoIdentifierParameter metaInfoItem) { + public CreateUpdateProducts putMetaInfoItem(String key, Object metaInfoItem) { if (this.metaInfo == null) { this.metaInfo = new HashMap<>(); } @@ -331,16 +330,16 @@ public CreateUpdateProducts putMetaInfoItem(String key, GetContactInfoIdentifier */ @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_META_INFO) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS) - public Map getMetaInfo() { + public Map getMetaInfo() { return metaInfo; } @JsonProperty(JSON_PROPERTY_META_INFO) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setMetaInfo(@jakarta.annotation.Nullable Map metaInfo) { + @JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS) + public void setMetaInfo(@jakarta.annotation.Nullable Map metaInfo) { this.metaInfo = metaInfo; } @@ -597,9 +596,13 @@ public String toUrlQueryString(String prefix) { // add `metaInfo` to the URL query string if (getMetaInfo() != null) { for (String _key : getMetaInfo().keySet()) { - if (getMetaInfo().get(_key) != null) { - joiner.add(getMetaInfo().get(_key).toUrlQueryString(String.format("%smetaInfo%s%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix)))); + try { + joiner.add(String.format("%smetaInfo%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMetaInfo().get(_key), URLEncoder.encode(String.valueOf(getMetaInfo().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); } } } diff --git a/brevo-java-client/src/generated/java/software/xdev/brevo/model/UpdateContact.java b/brevo-java-client/src/generated/java/software/xdev/brevo/model/UpdateContact.java index 4aa8793..f572c4f 100644 --- a/brevo-java-client/src/generated/java/software/xdev/brevo/model/UpdateContact.java +++ b/brevo-java-client/src/generated/java/software/xdev/brevo/model/UpdateContact.java @@ -25,7 +25,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import software.xdev.brevo.model.CreateDoiContactAttributesValue; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonTypeName; import java.io.UnsupportedEncodingException; @@ -48,7 +47,7 @@ public class UpdateContact { public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; @jakarta.annotation.Nullable - private Map attributes = new HashMap<>(); + private Map attributes = new HashMap<>(); public static final String JSON_PROPERTY_EXT_ID = "ext_id"; @jakarta.annotation.Nullable @@ -77,13 +76,13 @@ public class UpdateContact { public UpdateContact() { } - public UpdateContact attributes(@jakarta.annotation.Nullable Map attributes) { + public UpdateContact attributes(@jakarta.annotation.Nullable Map attributes) { this.attributes = attributes; return this; } - public UpdateContact putAttributesItem(String key, CreateDoiContactAttributesValue attributesItem) { + public UpdateContact putAttributesItem(String key, Object attributesItem) { if (this.attributes == null) { this.attributes = new HashMap<>(); } @@ -97,16 +96,16 @@ public UpdateContact putAttributesItem(String key, CreateDoiContactAttributesVal */ @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_ATTRIBUTES) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS) - public Map getAttributes() { + public Map getAttributes() { return attributes; } @JsonProperty(JSON_PROPERTY_ATTRIBUTES) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setAttributes(@jakarta.annotation.Nullable Map attributes) { + @JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS) + public void setAttributes(@jakarta.annotation.Nullable Map attributes) { this.attributes = attributes; } @@ -368,9 +367,13 @@ public String toUrlQueryString(String prefix) { // add `attributes` to the URL query string if (getAttributes() != null) { for (String _key : getAttributes().keySet()) { - if (getAttributes().get(_key) != null) { - joiner.add(getAttributes().get(_key).toUrlQueryString(String.format("%sattributes%s%s", prefix, suffix, - "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix)))); + try { + joiner.add(String.format("%sattributes%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getAttributes().get(_key), URLEncoder.encode(String.valueOf(getAttributes().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); } } } diff --git a/brevo-java-client/src/main/java/software/xdev/brevo/IdentifierType.java b/brevo-java-client/src/main/java/software/xdev/brevo/IdentifierType.java new file mode 100644 index 0000000..776cb4d --- /dev/null +++ b/brevo-java-client/src/main/java/software/xdev/brevo/IdentifierType.java @@ -0,0 +1,30 @@ +/* + * Copyright © 2024 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.brevo; + +public final class IdentifierType +{ + public static final String EMAIL = "email_id"; + public static final String CONTACT = "contact_id"; + public static final String EXT = "ext_id"; + public static final String PHONE = "phone_id"; + public static final String WHATSAPP = "whatsapp_id"; + public static final String LANDLINE = "landline_number_id"; + + private IdentifierType() + { + } +} diff --git a/openapi/INFO.md b/openapi/INFO.md index 0e67623..cd33749 100644 --- a/openapi/INFO.md +++ b/openapi/INFO.md @@ -1,5 +1,13 @@ This ``openapi.yml`` is based on the [official available one](https://api.brevo.com/v3/swagger_definition_v3.yml) with minor modifications. +Changes: +* Replaced + ```yaml + additionalProperties: + oneOf: + ``` + with ``additionalProperties: true`` as it can't be generated correctly otherwise + The Java API Client can be generated using ``mvn clean compile -P openapi-generator`` inside [``brevo-java-client``](../brevo-java-client/). Helpful links: diff --git a/openapi/openapi.yml b/openapi/openapi.yml index da665e1..a1594fc 100644 --- a/openapi/openapi.yml +++ b/openapi/openapi.yml @@ -22755,14 +22755,7 @@ components: example: elly@example.com attributes: type: object - additionalProperties: - oneOf: - - type: number - - type: string - - type: boolean - - type: array - items: - type: string + additionalProperties: true description: | Pass the set of attributes and their values. **These attributes must be present in your Brevo account**. For eg. **{'FNAME':'Elly', 'LNAME':'Roger', 'COUNTRIES':['India','China']}** example: @@ -22811,14 +22804,7 @@ components: example: 'externalId' attributes: type: object - additionalProperties: - oneOf: - - type: number - - type: string - - type: boolean - - type: array - items: - type: string + additionalProperties: true description: | Pass the set of attributes and their values. The attribute's parameter should be passed in capital letter while creating a contact. Values that don't match the attribute type (e.g. text or string in a date attribute) will be ignored. **These attributes must be present in your Brevo account.**. For eg: **{"FNAME":"Elly", "LNAME":"Roger", "COUNTRIES":["India","China"]}** @@ -22862,14 +22848,7 @@ components: properties: attributes: type: object - additionalProperties: - oneOf: - - type: number - - type: string - - type: boolean - - type: array - items: - type: string + additionalProperties: true description: | Pass the set of attributes to be updated. **These attributes must be present in your account**. To update existing email address of a contact with the new one please pass EMAIL in attributes. For example, **{ "EMAIL":"newemail@domain.com", "FNAME":"Ellie", "LNAME":"Roger", "COUNTRIES":["India","China"]}**. The attribute's parameter should be passed in capital letter while updating a contact. Values that don't match the attribute type (e.g. text or string in a date attribute) will be ignored. Keep in mind transactional attributes can be updated the same way as normal attributes. Mobile Number in **SMS** field should be passed with proper country code. For example: **{"SMS":"+91xxxxxxxxxx"} or {"SMS":"0091xxxxxxxxxx"}** @@ -25774,10 +25753,7 @@ components: format: string metaInfo: type: object - additionalProperties: - oneOf: - - type: string - - type: integer + additionalProperties: true description: Meta data of product such as description, vendor, producer, stock level. The size of cumulative metaInfo shall not exceed **1000 KB**. Maximum length of metaInfo object can be 20. example: { "description" : "Shoes for sports", @@ -25860,10 +25836,7 @@ components: format: string metaInfo: type: object - additionalProperties: - oneOf: - - type: string - - type: integer + additionalProperties: true description: Meta data of product such as description, vendor, producer, stock level. The size of cumulative metaInfo shall not exceed **1000 KB**. Maximum length of metaInfo object can be 20. example: { "description" : "Shoes for sports", diff --git a/pom.xml b/pom.xml index d0fbdd0..72ac952 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ com.puppycrawl.tools checkstyle - 10.26.1 + 11.0.0 @@ -82,12 +82,12 @@ net.sourceforge.pmd pmd-core - 7.15.0 + 7.16.0 net.sourceforge.pmd pmd-java - 7.15.0 + 7.16.0