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

$id was deserialized into example values #5139

Open
ArcturusZhang opened this issue Nov 5, 2024 · 1 comment
Open

$id was deserialized into example values #5139

ArcturusZhang opened this issue Nov 5, 2024 · 1 comment
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. DPG Mgmt This issue is related to a management-plane library.

Comments

@ArcturusZhang
Copy link
Member

ArcturusZhang commented Nov 5, 2024

The examples might have raw values in them, and they might be json, for instance, in a case that the property takes unknown as its type.

In this case, we will have:

{
	"examples": {
		"parameters": [
			{
				"$id": "100",
				"parameter": {
					"$ref": "10",
				},
				"value": {
					"$id": "101",
					"kind": "unknown",
					"type": {
						"$ref": "11",
					},
					"value": {
						"$id": "12",
						"free": "form",
						"json": [1, 2, 3]
					}
				}
			}
		]
	}
}

Here we have a parameter and its type is unknown, which accepts anything. In the example, its value is a json:

{
	"free": "form",
	"json": [1, 2, 3]
}

our rule of stringify-with-refs adds $id to everything which is an object, it does not care if the object is actually an object value in examples, therefore in the result json, you could see this json also has an $id.
As a result, this $id was deserialized into a dictionary as if the example value has it, and this leads to this: Azure/azure-sdk-for-net#46946 (comment)

This is a bug because we introduce values that do not exist in the example json, and we should fix it.

Even worse when the value has nested json object, it will become:

{
	"$id": "12",
	"free": "form",
	"json": [1, 2, 3],
	"object": {
		"$id": "13",
		"a": 10
	}
}

therefore we have more $id properties in the value which is incorrect.

@ArcturusZhang ArcturusZhang self-assigned this Nov 5, 2024
@ArcturusZhang ArcturusZhang added Mgmt This issue is related to a management-plane library. bug This issue requires a change to an existing behavior in the product in order to be resolved. DPG labels Nov 5, 2024
@ArcturusZhang
Copy link
Member Author

One possible solution of solving this might be overhauling all the functionalities from stringify-with-refs library into our own code, and this also contributes to this feature because we want to remove that dependency.
If we could control which model should be stringified with refs, this should be solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. DPG Mgmt This issue is related to a management-plane library.
Projects
None yet
Development

No branches or pull requests

1 participant