Skip to content

[sc-73945] Extend decisions property of DecisionResponse schema#96

Closed
tomascasas wants to merge 4 commits intomasterfrom
tomascasas/sc-73945/java-sdk-converting-long-ints
Closed

[sc-73945] Extend decisions property of DecisionResponse schema#96
tomascasas wants to merge 4 commits intomasterfrom
tomascasas/sc-73945/java-sdk-converting-long-ints

Conversation

@tomascasas
Copy link
Contributor

Allow single (dynamic key name) and multi-winner shapes.

Allow single (dynamic key name) and multi-winner shapes.
@tomascasas tomascasas changed the title [sc-sc-73945] Extend decisions property of DecisionResponse schema [sc-73945] Extend decisions property of DecisionResponse schema Aug 8, 2025
@tomascasas tomascasas force-pushed the tomascasas/sc-73945/java-sdk-converting-long-ints branch from 7bcc57c to 1acb82d Compare August 8, 2025 19:46
Copy link
Contributor

@akiradev akiradev Aug 9, 2025

Choose a reason for hiding this comment

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

I think I had interpreted the Multi-Winner Placements docs incorrectly and gave you misleading information. The key can be dynamic for Multi-Winner and passed in the same way via the divName parameter.

This alternative definition should also make use of additionalProperties.

So the valid types become: Map<string, Decision> or Map<string, Decision[]>.

The other thing I'm not 100% on is whether the object is limited to one property, so it might be good to exclude these restrictions for now.

Copy link
Contributor

@akiradev akiradev Aug 11, 2025

Choose a reason for hiding this comment

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

The other thing I'm not 100% on is whether the object is limited to one property, so it might be good to exclude these restrictions for now.

placements in the request body:

Every request must contain one or more placements. Each placement represents a "slot" in which an ad may be served.

So the decision response must support multiple properties under decisions, its values being a mixture of Decision and Decision[].

@tomascasas
Copy link
Contributor Author

tomascasas commented Aug 9, 2025 via email

@tomascasas tomascasas requested a review from akiradev August 11, 2025 14:24
@lqrs
Copy link
Contributor

lqrs commented Aug 11, 2025

I attempted to build the Java SDK using the changes, but the compilation failed with the following errors:

    method RequestBody.create(MediaType,String) is not applicable
      (argument mismatch; String cannot be converted to MediaType)
    method RequestBody.create(MediaType,ByteString) is not applicable
      (argument mismatch; String cannot be converted to MediaType)
    method RequestBody.create(MediaType,byte[]) is not applicable
      (argument mismatch; String cannot be converted to MediaType)
    method RequestBody.create(MediaType,File) is not applicable
      (argument mismatch; String cannot be converted to MediaType)
/home/keveldev/SDKs/adzerk-api-specification/build/decision-java/src/main/java/com/adzerk/sdk/generated/model/DecisionResponse.java:84: error: cannot find symbol
      this.decisions = new HashMap<String, AnyOfDecisionarray>();
                                           ^
  symbol:   class AnyOfDecisionarray
  location: class DecisionResponse

It looks like anyOf is not supported by openapi's generator.

@akiradev
Copy link
Contributor

akiradev commented Aug 11, 2025

I attempted to build the Java SDK using the changes, but the compilation failed with the following errors:

    method RequestBody.create(MediaType,String) is not applicable
      (argument mismatch; String cannot be converted to MediaType)
    method RequestBody.create(MediaType,ByteString) is not applicable
      (argument mismatch; String cannot be converted to MediaType)
    method RequestBody.create(MediaType,byte[]) is not applicable
      (argument mismatch; String cannot be converted to MediaType)
    method RequestBody.create(MediaType,File) is not applicable
      (argument mismatch; String cannot be converted to MediaType)
/home/keveldev/SDKs/adzerk-api-specification/build/decision-java/src/main/java/com/adzerk/sdk/generated/model/DecisionResponse.java:84: error: cannot find symbol
      this.decisions = new HashMap<String, AnyOfDecisionarray>();
                                           ^
  symbol:   class AnyOfDecisionarray
  location: class DecisionResponse

It looks like anyOf is not supported by openapi's generator.

@ryuichis Could you retry using a more recent version of the openapi generator?

Current version is set to 5.1.0 in https://github.com/adzerk/adzerk-api-specification/blob/master/openapitools.json.

Find latest version: 7.14.0 npx @openapitools/openapi-generator-cli version-manager list

@lqrs
Copy link
Contributor

lqrs commented Aug 12, 2025

@ryuichis Could you retry using a more recent version of the openapi generator?

Updating openapi-generator-cli to 7.14.0 made it compile. Thanks.

@akiradev
Copy link
Contributor

akiradev commented Aug 12, 2025

@ryuichis @tomascasas I've been testing the classes compiled using 7.14.0 with the option "disallowAdditionalPropertiesIfNotPresent": false in decision/codegen-config/java.json. There are too many breaking changes and would be burdensome for consumers to migrate to this new SDK.

I propose the decisions property to remain as an object without a defined schema.

This was originally changed to conform the decisions to the Decision schema so that long integers such as IDs were parsed correctly as integers rather than in scientific notation in the Java SDK adzerk/adzerk-decision-sdk-java#32. However this also introduced a regression in the Java SDK as now it would only support single placements. I have added a notice to consumers for that release to let them know of this breaking change https://github.com/adzerk/adzerk-decision-sdk-java/releases/tag/v1.0.0-beta.15.

We should rollback the Java SDK and apply a different fix to how gson parses the values.

@akiradev akiradev closed this Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments