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

CP-2062 - Generate credentials and dashboards after changes #11

Closed
wants to merge 5 commits into from

Conversation

phpinhei-te
Copy link
Contributor

@phpinhei-te phpinhei-te commented Apr 22, 2024

Two samples generated from code on PR/9.
Some examples are missing fields, depending on this BUG to be fixed on the generator.

@@ -55,7 +56,7 @@
import java.util.Set;
import java.util.function.Consumer;

@jakarta.annotation.Generated(value = "com.thousandeyes.api.codegen.ThousandeyesJavaGenerator", date = "2024-04-22T10:43:50.463323+01:00[Europe/London]")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ffs do we really need this timestamp ? ends up adding unnecessary changes to PR

Copy link
Contributor

Choose a reason for hiding this comment

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

We can add hideGenerationTimestamp: true to common.yaml... although, since this is a custom template we can just remove the timestamps from the template entirely 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it adds value once this is auto generated, then we know what has changed, but rn it is just adding more file changes to PRs 😢

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it adds value once this is auto generated

I thought the same initially, but I'm not even so sure any more... in the post-release action I assume we're going to regenerate all the SDKs using the latest OAS, and so presumably we'll have the same problem (albeit with more automation)

Or do you mean we'll be able to know which models need to be regenerated, and only those will be generated/updated?

@@ -82,7 +82,7 @@ public class Example {
### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/hal+json, application/problem+json
- **Accept**: application/hal+json, application/json, application/problem+json
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding application/json to all

@@ -223,8 +224,8 @@ private ApiRequest.ApiRequestBuilder getTransactionTestsCredentialDetailsRequest
requestBuilder.queryParams(localVarQueryParams);
}

requestBuilder.header("Accept", List.of("application/hal+json, application/problem+json"));
requestBuilder.header("User-Agent", List.of("ThousandEyesSDK-Java/7.0.0"));
requestBuilder.header("Accept", List.of("application/hal+json, application/json, application/problem+json"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

application/json added to endpoints with request

@@ -169,7 +170,7 @@ private ApiRequest.ApiRequestBuilder deleteTransactionTestsCredentialRequestBuil
}

requestBuilder.header("Accept", List.of("application/problem+json"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

but not yet added to endpoints without requests

*/

@Test
public void createTransactionTestsCredentialRequestAndResponseDeserializationTest()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good example with proper example generated

*
* @throws JsonProcessingException if the deserialization fails
*/
@Disabled
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No request nor response, disabled test

*/

@Test
public void getTransactionTestsCredentialDetailsRequestAndResponseDeserializationTest()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bad example generation because of the composed schema bug

throws JsonProcessingException
{

String responseBodyJson = """
Copy link
Contributor Author

Choose a reason for hiding this comment

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

} ]
""";
List<ApiDashboard> mappedResponse =
mapper.readValue(responseBodyJson, new TypeReference<List<ApiDashboard>>(){});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TypeReference handling for list responses

"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"type" : "Agent Status",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

widgets are missing attributes bcs of the bug

{
String requestBodyJson = """
{
"context" : [ {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unless maxItems is defined on OAS, by default, the ExampleGenerator will add 2 examples for every array

@phpinhei-te phpinhei-te marked this pull request as ready for review April 22, 2024 11:24
@phpinhei-te phpinhei-te requested a review from a team April 22, 2024 11:24
""";
CredentialRequest mappedRequest =
mapper.readValue(requestBodyJson, CredentialRequest.class);
assertNotNull(mappedRequest);
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible/easy to verify the fields have values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

possible ? most likely yea, by using reflection, but easy ? I dont think so.
If this was on the model test would be a lot easier, cause the model codegen has all its fields and whether they are required and what not, but here on the operation cogeden we only have the reference :/

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.

4 participants