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

improvement: update 'any object' examples to be flatter #4083

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

armandobelardo
Copy link
Contributor

Previously, we'd create nested objects if we received an any object e.g. an unknown value we're binding to an object (since we make those map<string, unknown>).
Those generated examples would become: "object": {"object": {"key": "value"}}, now we short circuit the example generation to special case map<string, unknown> to just return {"key": "value"}, making the above now "object": {"key": "value"}

As a bonus I also changed the map key and value generation to fall back to "key" and "value" as opposed to the field name which led to some awkward examples like {"custom_fields": "custom_fields" } seen below

@armandobelardo armandobelardo requested a review from dsinghvi as a code owner July 19, 2024 11:50
@@ -596,25 +588,17 @@ Creates a new document index.",
{
"key": {
"type": "string",
"value": "indexing_config",
"value": "key",
Copy link
Member

Choose a reason for hiding this comment

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

any thoughts on why the value here is now key ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chatted offline, but this was similarly intentional for the same reason as the other comment! And since these are the example TRs, this is what we wanna see

@@ -974,11 +974,11 @@ exports[`generate IR from OpenAPI 1`] = `
"map": [
{
"key": {
"jsonExample": "custom_fields",
"jsonExample": "key",
Copy link
Member

Choose a reason for hiding this comment

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

similar issue here with custom_fields -> key

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one's intentional, it's outlined at the end of the pr body, but since it was {"custom_fields": "custom_fields"} I updated to {"key": "value"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants