Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

SchemaContract value field is not being populated when calling apiSchema.get #4718

Closed
awaldow opened this issue Feb 21, 2019 · 8 comments
Closed

Comments

@awaldow
Copy link

awaldow commented Feb 21, 2019

required: false,
serializedName: 'properties.document.value',
type: {

I was attempting to use the apiManagementClient to pull down the schema for one of my APIs and noticed the returned response did not contain the document itself, just the metadata. Upon further investigation, I noticed that deep down in the _get call for apiSchema.js the document is indeed being returned, but after a pass through serialization.js it is being stripped because (I think) the serializedName in the schema contract is not valid. It is looking for properties.document.value but there is just properties.document and properties.document.definition et al once it passes through a JSON.parse here:

let parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined) {

@awaldow
Copy link
Author

awaldow commented Feb 21, 2019

To provide some additional context, the following screenshots tell the story around line 570 of apiSchema.js.

First, the responseBody object as it is before it's been parsed:
apischema responsebody

Though I could not show the whole thing, if you were to look through the document object further you would see nothing beyond the definitions child.

Then, the parsedResponse at line 570 looks as follows:
apischema parsedresponse

documents contains no value object.

And then, the result object being returned on line 574 after deserializing:
apischema result

The document object has disappeared in its entirety. I had entertained the notion that maybe a .value at the end of a serializedName just meant "give me this object" but I see nothing in serialization.js to support that assertion. I should also note that apiSchema.listByApi suffers from this issue as well.

@awaldow
Copy link
Author

awaldow commented Feb 22, 2019

So just to test, I went into my node_modules and removed the '.value' part of the serializedName so it was just 'properties.document'. I was then able to get a json reconstruction of the definitions of the schema. I am wondering how to get the YAML definition in its entirety but sending Content-Type 'application/vnd.oai.openapi' doesn't seem to change anything, I always just get the definitions, but that's a separate issue from this, though I would like some answer as to how one would get that.

@awaldow
Copy link
Author

awaldow commented Mar 5, 2019

Is there a better place to raise this issue? It seems like the return content type is going to dictate whether you have this issue or not and with no mechanism to change that to get around it my project is essentially on hold.

@amarzavery
Copy link
Contributor

@solankisamir from the api management team can help you in this issue.

@solankisamir
Copy link
Member

yes.. this is an issue in the Contract. The schema document should just be properties.document

We also support Wsdl (SOAP) based APIs. For those apis the schema document is accessible at properties.document.value

@solankisamir
Copy link
Member

@awaldow we are working on fixing it, give it a week to reach to all clients.

@awaldow
Copy link
Author

awaldow commented May 2, 2019

Thanks guys, this will help me a ton

@solankisamir
Copy link
Member

Try this package https://www.npmjs.com/package/azure-arm-apimanagement/v/5.1.0

The properties.Document is now a JObject and you should be able to retrieve it.
https://docs.microsoft.com/en-us/rest/api/apimanagement/apischema/createorupdate#schemacontract

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants