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

[BUG] Serialization of customized models missing properties #47612

Open
kinelski opened this issue Dec 18, 2024 · 1 comment
Open

[BUG] Serialization of customized models missing properties #47612

kinelski opened this issue Dec 18, 2024 · 1 comment
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. Cognitive - Form Recognizer

Comments

@kinelski
Copy link
Member

Code example

var options = new ClassifyDocumentOptions("my_classifier_id", new Uri("https://myuri.com/"));
var jOptions = new JsonSerializerOptions()
{
    Converters = { new JsonModelConverter() }
};
var serial = JsonSerializer.Serialize(options, jOptions);

Behavior

Classifier ID is not present in the serialized string:

{
  "urlSource": "https://myuri.com/"
}

Cause

ClassifierId, as well as properties Split and Pages, were added in the custom code layer and not part of the output of our code generator. For this reason, the generated logic for serializing/deserializing this model does not take into account these custom properties.

Solution

We must write custom code for methods JsonModelWriteCore and DeserializeClassifyDocumentOptions, which are responsible for serializing and deserializing this model, respectively. However, during serialization we must be careful to not duplicate these extra properties when sending a REST request to the Document Intelligence service.

Affected models

Any models with additional custom properties could be affected by this bug. These are the models that are likely to be affected:

  • AnalyzeBatchDocumentsOptions
  • AnalyzeDocumentOptions
  • ClassifyDocumentOptions

The following models have custom properties but may not be affected given the nature of the custom code:

  • AnalyzedDocument
  • BuildDocumentModelOptions
  • ClassifierDocumentTypeDetails
  • DocumentField
@kinelski kinelski added bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. Cognitive - Form Recognizer labels Dec 18, 2024
@kinelski kinelski self-assigned this Dec 18, 2024
@jaliyaudagedara
Copy link

Tagging myself in

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. Client This issue points to a problem in the data-plane of the library. Cognitive - Form Recognizer
Projects
None yet
Development

No branches or pull requests

2 participants