Exemplo n.º 1
0
            private RequestContract BuildRequest()
            {
                if (_operation == null)
                {
                    throw new SwaggerResourceException("Operation is required");
                }

                RepresentationContract[] representations = null;
                if (this._operation.Consumes != null && this._operation.Consumes.Count > 0)
                {
                    representations = new RepresentationContract[]
                    {
                        RepresentationContract.Create(this._operation.Consumes[0], null, null, null, _formDataParameters.ToArray())
                    };
                }
                else if (_formDataParameters.Count > 0)
                {
                    representations = new RepresentationContract[]
                    {
                        RepresentationContract.Create("application/json", null, null, null, _formDataParameters.ToArray())
                    };
                }


                OperationRequestBuilder rBuilder = new OperationRequestBuilder()
                {
                    Description = _operation.Description,
                    Headers     = _headerParameters.ToArray(),
                    //Queries = _queryParameters.ToArray(),
                    Representations = representations
                };

                return(rBuilder.BuildRequest());
            }
Exemplo n.º 2
0
 public ResponseContract BuildResponse()
 {
     RepresentationContract[] representations =
     {
         RepresentationContract.Create("application/json", null, GetSchemaDefinition(), GetResponseSampleCode(), null)
     };
     return(ResponseContract.Create(GetStatusCode(), _response.Description, representations));
 }
Exemplo n.º 3
0
 private ResponseContract[] Responses()
 {
     ResponseContract[] responses =
     {
         ResponseContract.Create(200,                          "OK!",     new RepresentationContract[] {
             RepresentationContract.Create("application/json", null,      "typeName", null, null),
             RepresentationContract.Create("text/json",        null,      "typeName", "sample data", Parameters()),
         }),
         ResponseContract.Create(201,                          "Created", null),
     };
     return(responses);
 }