That's just how CORS works. When you post a body it must do a preflight check 
via options. Posting with www-form-urlencoded will not

> On Aug 2, 2016, at 7:51 AM, Abhishek Goswami <[email protected]> wrote:
> 
> Hello everybody,
> Still facing the same problem with my API . OPTIONS method fire when i 
> request POST method. But it works fine when it is GET or POST method with 
> formData value. But when i send POST with body data its request method 
> changes to OPTIONS Method.   
> 
>> On Friday, 7 November 2014 21:22:41 UTC+5:30, [email protected] wrote:
>> Hi,
>> 
>> I have a problem with SWAGGER-UI. When I try to call the REST operation 
>> SWAGGER always sends an OPTIONS method instead of GET / POST / PUT or DELETE.
>> I have no clue why.
>> 
>> Here is my json:
>> {
>>     "apiVersion": "1.0.0",
>>     "swaggerVersion": "1.2",
>>    "basePath": "http://localhost:9999/lazydoc-spring";,
>>    "resourcePath": "/customers",
>>    "apis": [
>>        {
>>            "path": "/customers",
>>            "description": "Creates a new customer",
>>            "operations": [
>>                 {
>>    "method": "POST",
>>    "nickname": "createCustomer",
>>    "type": "Customer",
>>    "summary": "Creates a new customer",
>>    "notes": "",
>>    "authorization": {
>> 
>>    },
>>    "errorResponses": [],
>>    "parameters": [
>>       {
>>          "paramType": "body",
>>          "name": "requestBody",
>>          "description": "The data of the customer to be created",
>>          "type": "Customer",
>>          "required": true,
>>          "allowMultiple": false,
>>          "list": false
>>       }
>>    ],
>>    "responseMessages": [
>>       {
>>          "code": 400,
>>          "message": "Invalid ID supplied"
>>       },
>>       {
>>          "code": 404,
>>          "message": "Pet not found"
>>       },
>>       {
>>          "code": 405,
>>          "message": "Validation exception"
>>       }
>>    ]
>> }
>>            ]
>>        },
>>        {
>>            "path": "/customers/{customerId}",
>>            "description": "Deletes the customer for the given id",
>>            "operations": [
>>                 {
>>    "method": "DELETE",
>>    "nickname": "deleteCustomer",
>>    "responseClass": "void",
>>    "parameters": [
>>        {
>>    "paramType": "path",
>>    "name": "customerId",
>>    "description": "The id of the customer to be updated",
>>    "type": "long",
>>    "required": true,
>>    "allowMultiple": false,
>>    "list": false
>> }
>> 
>>    ],
>>    "summary": "Deletes the customer for the given id",
>>    "notes": "",
>>    "authorization": "",
>>    "errorResponses": []
>> }
>>            ]
>>        },
>>        {
>>            "path": "/customers/{customerId}",
>>            "description": "Returns the customer for the given id",
>>            "operations": [
>>                 {
>>    "method": "GET",
>>    "nickname": "getCustomer",
>>    "responseClass": "Customer",
>>    "parameters": [
>>        {
>>    "paramType": "path",
>>    "name": "customerId",
>>    "description": "The id of the customer to be updated",
>>    "type": "long",
>>    "required": true,
>>    "allowMultiple": false,
>>    "list": false
>> }
>> 
>>    ],
>>    "summary": "Returns the customer for the given id",
>>    "notes": "",
>>    "authorization": "",
>>    "errorResponses": []
>> }
>>            ]
>>        },
>>        {
>>            "path": "/customers",
>>            "description": "Returns all customers",
>>            "operations": [
>>                 {
>>    "method": "GET",
>>    "nickname": "getCustomers",
>>    "responseClass": "List[Customer]",
>>    "parameters": [
>> 
>>    ],
>>    "summary": "Returns all customers",
>>    "notes": "",
>>    "authorization": "",
>>    "errorResponses": []
>> }
>>            ]
>>        },
>>        {
>>            "path": "/customers/{customerId}",
>>            "description": "Updates a customer specified by the id",
>>            "operations": [
>>                 {
>>    "method": "PUT",
>>    "nickname": "updateCustomer",
>>    "responseClass": "Customer",
>>    "parameters": [
>>        {
>>    "paramType": "path",
>>    "name": "customerId",
>>    "description": "The id of the customer to be updated",
>>    "type": "long",
>>    "required": true,
>>    "allowMultiple": false,
>>    "list": false
>> }
>> ,
>>        {
>>    "paramType": "form",
>>    "name": "requestBody",
>>    "description": "The data of the customer to be created",
>>    "type": "Customer",
>>    "required": true,
>>    "allowMultiple": false,
>>    "list": false
>> }
>> 
>>    ],
>>    "summary": "Updates a customer specified by the id",
>>    "notes": "",
>>    "authorization": "",
>>    "errorResponses": []
>> }
>>            ]
>>        }   ],
>>    "models": {
>>            "Customer": {
>>    "properties": {
>>          "city": {
>>               "type": "String",
>>               "description": "The city of the customer's address",
>>               "required": false,
>>               "request": true,
>>               "response": true,
>>               "list": false
>>            },
>>          "customerId": {
>>               "type": "long",
>>               "description": "The unique identifier of the customer",
>>               "required": false,
>>               "request": true,
>>               "response": true,
>>               "list": false
>>            },
>>          "firstname": {
>>               "type": "String",
>>               "description": "The firstname of the customer",
>>               "sample": "Maxi",
>>               "required": false,
>>               "request": true,
>>               "response": true,
>>               "list": false
>>            },
>>          "lastname": {
>>               "type": "String",
>>               "description": "The lastname of the customer",
>>               "sample": "Miller",
>>               "required": false,
>>               "request": true,
>>               "response": true,
>>               "list": false
>>            },
>>          "street": {
>>               "type": "String",
>>               "description": "The street of the customer's address",
>>               "sample": "Effnerstr. 5",
>>               "required": false,
>>               "request": true,
>>               "response": true,
>>               "list": false
>>            },
>>          "zipCode": {
>>               "type": "String",
>>               "description": "The zipcode of the customer's address",
>>               "required": false,
>>               "request": true,
>>               "response": true,
>>               "list": false
>>            }
>>    }
>> }
>>    }
>> }
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Swagger" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to