Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jcapellman/jcpvs
https://github.com/jcapellman/jcpvs
Last synced: about 5 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/jcapellman/jcpvs
- Owner: jcapellman
- License: mit
- Created: 2016-01-17T01:09:54.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-24T21:23:12.000Z (almost 9 years ago)
- Last Synced: 2024-04-28T01:11:27.847Z (7 months ago)
- Language: C#
- Size: 23 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jcPVS
A handy library to add versioning request support to WebAPI Responses. Eventually I plan to add in support for handling entirely different endpoints.
The idea for doing this little library was to handle the scenarios where you made a change to your WebAPI service that adds a new property to the JSON response. All well and good, however if you have native apps across the board with varying times of approval (Apple Store vs Google Play/Windows) and coordinating client upgrades of platforms this becomes far more challenging that the code itself. Thus the idea that you can tag attributes inside DataContract with a version number and it would dynamically remove the properties that aren't available to the client requesting the data.
Trying to make the implementation easy, I've provided a WebAPI service that implements a test object to get you started, but if you have an existing WebAPI Service follow the steps below.
1. Add the jcPVSMediaFormatter to the WebApiConfig class
In the Register function add the following lines right after the opening line of the function.```csharp
config.Formatters.Clear();
config.Formatters.Add(new jcPVSMediaFormatter());
```2. Add the jcPVS attribute with an API Version to restrict properties
```csharp
public class TestObject {
[jcPVS(125)]
public string Name { get; set; }public int ID { get; set; }
}
```3. Either tag your controller with the jcPVSActionFilter or use the jcPVSAPIController
At this point you can either tag your endpoints in your Controller with the jcPVSActionFilter. This ActionFilter takes the API_VERSION passed from the Client and adds it to the Content Header to be used in the MediaTypeFormatter.4. Add API_VERSION to your HttpClient
As mentioned in step 3, you'll need to add API_VERSION to your HttpClient's Header Content.If you have any questions please email me at jarred at jarredcapellman.com