Skip to content

[BUG] Serialization of customized models missing properties #47612

Open
@kinelski

Description

@kinelski

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

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.Cognitive - Form RecognizerbugThis issue requires a change to an existing behavior in the product in order to be resolved.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions