| | | 1 | | using System.Text.Json; |
| | | 2 | | using Bpmn.Model; |
| | | 3 | | |
| | | 4 | | namespace Elsa.Bpmn.Interchange.Endpoints.Bpmn; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// The <see cref="JsonSerializerOptions"/> the <c>bpmn/definitions/{definitionId}/document</c> endpoints read and |
| | | 8 | | /// write a <see cref="BpmnDefinitions"/> document with. |
| | | 9 | | /// </summary> |
| | | 10 | | /// <remarks> |
| | | 11 | | /// <c>Bpmn.Model</c> declares every serialized property name explicitly through <c>[JsonPropertyName]</c> — see |
| | | 12 | | /// <see cref="BpmnPayloadFormat"/> — and carries no <c>[JsonConverter]</c> of its own, so its wire shape is |
| | | 13 | | /// plain <see cref="System.Text.Json.JsonSerializer"/> defaults: camelCase names exactly as declared, and any enum |
| | | 14 | | /// as its underlying integer. Elsa's own API-wide serializer (<c>Elsa.Workflows.Serialization.Serializers.ApiSerializer |
| | | 15 | | /// reached through FastEndpoints' configured <c>IApiSerializer</c>) adds a <c>JsonStringEnumConverter</c> and several |
| | | 16 | | /// other converters of its own, none of which this library's schema expects. Letting the document body go through |
| | | 17 | | /// that serializer, the way an ordinary FastEndpoints request or response DTO does, would silently write a shape |
| | | 18 | | /// <c>Bpmn.Model</c>'s own reader does not agree is the payload format it published — hence the document endpoints |
| | | 19 | | /// binding and writing the body explicitly with this instance instead of a request/response DTO. |
| | | 20 | | /// </remarks> |
| | | 21 | | internal static class BpmnDocumentJsonOptions |
| | | 22 | | { |
| | | 23 | | /// <summary>Plain <see cref="System.Text.Json"/> defaults, scoped to the document endpoints only.</summary> |
| | 1 | 24 | | public static readonly JsonSerializerOptions Value = new(); |
| | | 25 | | } |