swaggerwcf icon indicating copy to clipboard operation
swaggerwcf copied to clipboard

string[] Parameter, enum Return Value

Open marcobudde opened this issue 6 years ago • 3 comments

I have integrated SwaggerWcf 0.2.15.0 in our WCF (SOAP + REST) application.

While most of the API seems to be exported without problems, there are three methods, which are not exported correctly.

        [OperationContract]
        [WebGet]
        [SwaggerWcfTag("Camera")]
        CameraStatus GetCameraStatus(string cameraID);

        [OperationContract]
        [WebInvoke]
        [SwaggerWcfTag("Camera")]
        void SetUsedCameras(string[] cameraIDs);

        [OperationContract]
        [WebInvoke]
        [SwaggerWcfTag("Debug")]
        object[] GetData(string[] ids);

CameraStatus is an enum.

The endpoints are configured like this:

   restEndpoint = this.serviceHost.AddServiceEndpoint(typeof(CoreCommunication.Contracts.ICamera), bindingWeb, "Rest/Camera");
            restEndpoint.Behaviors.Add(new WebHttpBehavior() { DefaultOutgoingResponseFormat = System.ServiceModel.Web.WebMessageFormat.Json, DefaultBodyStyle = System.ServiceModel.Web.WebMessageBodyStyle.WrappedRequest });

For the first method the response references "#/definitions/Lap.CoreCommunication.Contracts.CameraStatus", but this type is not created.

For the second and third methods the responses are defined as array of "#/definitions/". This type is also missing.

marcobudde avatar Oct 05 '18 13:10 marcobudde

they are all Primitive Type, will be skipped.

justin0522 avatar Oct 08 '18 03:10 justin0522

The problem seems to be caused by setting the body style and format in WebHttpBehavior.

I have fixed the problem by settings BodyStyle, RequestFormat, and "ResponseFormat" in [WebInvoke] and [WebGet].

marcobudde avatar Oct 09 '18 13:10 marcobudde

ok, when use WebMessageBodyStyle.Wrapped & RequestFormat = WebMessageFormat.Xml, be carefull about the namespace of the datacontract

justin0522 avatar Oct 10 '18 01:10 justin0522