Don't configure JsonOptions by default, Orchard Harvest 2024 videos are up - This week in Orchard (08/11/2024)
Don't configure JsonOptions by default, and introducing DeploymentSourceBase to simplify DeploymentSource are the topics for this week. All of the recordings of Orchard Harvest 2024 are up on YouTube! Check out our post for the details!
Orchard Core updates
Don't configure JsonOptions by default
A key change in version 2.0 is the shift from Newtonsoft.Json to System.Text.Json. Previously, we configured the default JsonOptions to match the settings used for document serialization. In the upcoming release, however, the community reverted that approach, and the JsonOptions are no longer configured by default. This change provides greater flexibility, allowing you to customize JSON serialization as needed.
If your Minimal API returns YesSql documents, entities (implementations of IEntity), or content (implementations of IContent), such as ContentItem, User, Query, or Notification, you may need to use DocumentJsonSerializerOptions for proper serialization. For example, when using Minimal API, instead of returning the result with TypedResults.Ok(entity), you should use Results.Json(entity, options.Value.SerializerOptions), resolving IOptions<DocumentJsonSerializerOptions> from the IoC container.
For scenarios using ApiController to return YesSql documents or entities, we’ve introduced new output formatters, DocumentSystemTextJsonOutputFormatter and ContentSystemTextJsonOutputFormatter, to automatically handle document serialization to JSON correctly. Here, you can see, that we are injecting the IOptions<DocumentJsonSerializerOptions> into the HandleAsync method of the GetEndpoint endpoint.
These changes are non-breaking and you shouldn't need to change the working 2.0.x code.
Introduce DeploymentSourceBase to simplify DeploymentSource
A new abstract class, DeploymentSourceBase<TStep>, has been introduced to streamline and simplify deployment source implementations. Instead of directly implementing the IDeploymentSource interface, it is now recommended to inherit from DeploymentSourceBase<TStep>. This change reduces complexity and improves the maintainability of deployment sources.
Now, let's see quickly how you can utilize the new DeploymentSourceBase abstract class! Here, you can see that we inherited the AzureAISearchIndexDeploymentSource class from the DeploymentSourceBase. It means that from now on, we don't need to check the type of the DeploymentStep in the ProcessAsync method because it will be done by default in the base class for the deployment source.
News from the community
Orchard Harvest 2024 videos are up
The 7th Orchard Harvest Conference was held in Las Vegas on September 12th and 13th, 2024. We recorded every session, and now all of the recordings are published on the Orchard Core YouTube channel. If you haven't seen them yet, head to the channel for the Harvest videos!
Orchard Dojo Newsletter
Lombiq's Orchard Dojo Newsletter has 468 subscribers! We have started this newsletter to inform the community around Orchard of the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post is published to Orchard Dojo, including This week in Orchard of course.
Do you know of other Orchard enthusiasts who would like to read our weekly articles? Tell them to subscribe here!