Skip to content

Conversation

jhamon
Copy link
Contributor

@jhamon jhamon commented Apr 9, 2024

Backport fixes from #95

jhamon and others added 4 commits April 9, 2024 14:13
When new properties are added to API responses, this causes the Java
client to error. This prevents us from making additive API changes that
would otherwise be non-breaking to the end user.

- Add tests that exercise the JSON parsing behavior in
`src/test/java/org/openapitools/client/JsonParsingTest.java` and ensure
the presence of additional properties will not cause the SDK to error.
These tests use JSON fixtures added in `src/test/resources`.
- Regenerate the control plane rest client using the OpenAPI [java
client generator](https://openapi-generator.tech/docs/generators/java/).
This time, configuring the generator with
`disallowAdditionalPropertiesIfNotPresent=false` should activate the
correct JSON parsing behavior in the generated code.

The code generation step was performed with this command:

```bash
mkdir codegen
mkdir codegen/gen
cd codegen

docker run --rm -v $(pwd):/workspace openapitools/openapi-generator-cli:v7.0.1 generate \
    --input-spec $SPEC_FILE \
    --additional-properties=dateLibrary='java8',disallowAdditionalPropertiesIfNotPresent=false \
    --generator-name java \
    --output /workspace/gen/java

rm -rf ../src/main/java/org/openapitools/client

cp -r gen/java/src/main/java/org/openapitools/client ../src/main/java/org/openapitools/client
```

It took some trial and error to discover an openapi generator version
and spec version that produced similar results to the ones Rohan created
previously using steps and commands that were not captured anywhere.
These steps will be scripted and automated in a future PR to remove this
element of guesswork.

- [x] Bug fix (non-breaking change which fixes an issue)

Since the new tests exercise all the generated code up to the boundary
where a response is returned from the okhttp library used for making
requests, that gives a high confidence this will work if unexpected
fields appear in future API responses.
## Problem

Prepare for v0.8.1 release

## Solution

Update changelogs, sdk version, and the user-agent string to reflect
v0.8.1.

## Type of Change

- [X] Non-code change (docs, etc)

## Test Plan

NA
@rohanshah18 rohanshah18 deleted the jhamon/fix-additional-properties-0.8.x branch July 10, 2024 21:24
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.

2 participants