Skip to content
Jacek Gorgoń edited this page Aug 26, 2015 · 1 revision

Philosophy

NJsonApi aims to be idealistic in the internals but highly pragmatic on the outside.

A framework with few dependencies, well-defined specification and convenient tech stack has the potential of becoming a polished, well tested product with little to no room for dirty hacks - things that can't ultimately be eliminated in a real-life commercial project. Choosing these core principles seemed natural when building NJsonApi.

What's more important thought is how the framework interfaces with its consumers. NJsonApi strives to:

  • require no boilerplate code
  • be highly customizable
  • cover all standard, practical usage scenarios
  • give a simple, quick start with a relatively flat learning curve for customizations

Configuration

With the above mentioned attributes in mind, NJsonApi's behavior is determined by the following, with subsequent methods overriding the previous ones:

  1. Auto-discovery
  • default conventions
  • user-specified conventions
  1. Code Attributes (not yet implemented)
  2. Fluent API (builder style, general code configuration)
  3. Per-request code configuration (not yet implemented)

Autodiscovery

NJsonApi contains a fairly powerful, yet customizable auto-discovery mechanism that works on several levels:

Route scanning

Not yet implemented

Given an HttpConfiguration instance, the framework scans for exposed Web API routes. Each route found can yield an input and output class (method argument and return type) that can potentially be treated as JSON API resources. Depending on IRouteScanningConvention implementation, a set of resources may be discovered from these sources. Each of those will be passed on to resource class scanning

Resource class scanning

Each class representing a JSON API resource needs to have some mapping provided for the serializer to behave as expected, including:

  • link URL templates (e.g. self)
  • ID expression
  • attribute expressions
  • related resource expressions

By default, each class recognized (or passed on manually) as a JSON API resource is scanned to auto-discover those mappings based on conventions (all of which have default, overridable implmenentations)

  • IResourceTypeConvention
  • IPropertyScanningConvention
  • ILinkIdConvention
  • ILinkNameConvention

Some of the conventions might be renamed or broken down into more granular ones

Clone this wiki locally