I need to expose the rest API as OData service in Mulesoft. I have the below questions.
Is there an easy way/tool to convert openAPI spec to odata(RAML) to use it in APIKit router in mule4.
How we can define complex datatypes in odata.raml file.
You can use open api APIs directly with the last version of APKit and Studio without any conversions:
https://docs.mulesoft.com/release-notes/platform/oas3
On the other hand I'm not sure if you are trying to use OData. That's a different standard. See the instructions for the OData plugin: https://docs.mulesoft.com/apikit/4.x/creating-an-odata-api-with-apikit
You cant define complex data types in odata.raml, but you can now use apikit for odata 4
Related
I have a list of service contracts created in swagger, and I am trying to create WCF contracts based on that. As I see, I can use https://editor.swagger.io to convert swagger json to asp.net core server. But I can't seem to find anything that will help me convert this json to WCF contracts.
I thought of using SwaggerWCF nuget package, but that seems to allow only the conversion of WCF contracts to Swagger JSON, not the other way around. Is there something I am missing on that nuget package?
Or maybe there is some other tool that I can use to create WCF templates from Swagger?
you have swagger.json, you want to convert this json to WCF contracts.
1. convert json to .net class with SwaggerNet
2. create new assembly with System.Reflection.Emit.AssemblyBuilder
https://github.com/justin0522/SwaggerNet
Currently spring-data-rest is returning JSON in HAL format in a spring-boot project of mine. I am using an ember.js frontend and want to use jsonapi (http://jsonapi.org/) specification.
How might I register a new JSON formatting strategy given I will need to write the formatter myself as one does not exists yet?
This is how you can customize the HATEOAS that Spring Data REST produces:
https://docs.spring.io/spring-data/rest/docs/current/reference/html/#customizing-sdr.customizing-json-output
If you need to completely replace the JSON representation with your own, then you can write and register your own org.springframework.core.convert.converter
Or you write your custom REST endpoints in a plain old #RepositoryRestController and implement your own REST endpoints. (<= I suggest try this)
I want my OData service to support Json serialization, I read about a WCF Data Service toolkit which add this behaviour to the V2 version. After I read WCF Data Service released a new version of WCF Data Service 5.0, I need to know how to do it.
I add the $Format=json and I get all the time this attribute isn't supported.
Any suggestion .
Thanks in advance ...
The usual way to request JSON is to use Accept header (basically following HTTP, if the client wants a certain representation of the response, it should ask for it in the Accept header).
So if you send Accept: application/json;odata=verbose, you will get the Verbose JSON response.
WCF Data Services currently doesn't implement the $format query option. But you can add it "on top". There are several ways to do this (just search the web). One of them is for example here: http://archive.msdn.microsoft.com/DataServicesJSONP
I am going develop a WPF windows based application. I want to work with Entity Framework Self Tracking Entities and WCF. I was wondering if using Json is possible/recommended? If yes, please assist me; is there any tutorial that can help?
You can use the DataContractJsonSerializer to serialize the messages. You will have to use a REST based service (WebHttpBinding) as SOAP mandates XML as the message payload.
You can tell WCF to use the DatcontractJsonSerializer on the service side by settings in the WebGet and WebInvoke attributes but on the client side you will have to manually use this serializer as REST doesn;t have a metadata standard and therefore you have to create the requests and manage responses in a more manual fashion
Here is a reasonable guide to using Json and REST support in WCF
However, what is your driver to using Json? WCF is much more geared to SOAP based interaction currently (although the WCF 4.5 WebApi is going to address that to quite a degree). As your client is WPF you don't seem to gain alot from using Json
By default WCF use DataContractSerialization so if we can change it then my question is how to change it and when should we need which serialization on wcf ?
You can use the XmlSerializerFormatAttribute attribute on your service contract to force WCF to use the XmlSerializer.
WCF has a nice feature that a method can return Message or a Stream (see Returning raw json (string) in wcf and How to set Json.Net as the default serializer for WCF REST service as examples). The corresponding code which you need to write can be more easy as if you will use more advance techniques Extending Encoders and Serializers. So it is very easy to implement Streaming Message Transfer for example or just returning JPG or Excel file as a result of some WCF method.
The default choice of DataContractSerializer is good for most purpose. You can also use the DataContractJsonSerializer specially for REST type services and if the client expects Json content type. The other option is XmlSerializer for interoperability purpose if you need more control over the generated XML. DataContractSerializer is more efficient than XmlSerializer.
In 3rd party options you can use protobuf-net from Google which is more efficient than DataContract Serializer.