swagger editor UI sends a OPTIONS request method instead of PUT and DELETE - yaml

http://editor.swagger.io sends a OPTIONS request method instead of PUT and DELETE but for POST and GET it's work perfectly
even I have installed a Chrome extension that adds Access-Control-Allow-Origin to outgoing requests. and same added in the c# code like below
[EnableCors(origins: "", headers: "", methods: "*", exposedHeaders: "x-docname,x-docid")]
put:
tags:
- sources
summary: Updated sources Groups
description: This Will Create new Group under sources
operationId: PUT
consumes:
- application/x-www-form-urlencoded
produces:
- application/json
parameters:
- name: sourceId
in: path
description: name that need to be updated
required: true
type: string
- name: text
in: formData
description: Updated name of the text
required: true
type: string
responses:
200:
description: "Ok : Successful requests"
201:
description: "Created : Successful creation"
400:
description: "Bad Request : The path info doesn't have the right format"
403:
description: "Forbidden : The invoker is not authorized to invoke the operation"
404:
description: "Not Found : The object referenced by the path does not exist"
500:
description: "Internal Server Error : The execution of the service failed in some way"

Related

How is the actual Request URL generated from a custom connector api definition

Since there isn't currently a native databricks powerapps connector, I set up a custom connector that calls the jobs runnow api using an AD backed service principle bearer token. I then shared the custom connector and the connection with users for them to run. While this is working fine for everyone on my team, the actual end users are getting a 401 error response. Since everyone on my team are admins in Azure and Databricks, it's likely we have permissions that the end users don't. However, we're having a hard time pinpointing where that might be.
During PowerApps monitoring sessions, we did notice that the Request URL is different for the users getting successful 200 responses, versus those getting 401. The odd thing is, neither matches the specified host in the custom connector. Can anyone tell me how this is generated?
Here is the custom connector code we're using:
swagger: '2.0'
info: {title: Databricks Jobs, description: Call Databricks Jobs API,
version: '1.0'}
host: <databricksInstance>.azuredatabricks.net
basePath: /api/2.1/jobs/
schemes: [https]
consumes: []
produces: []
paths:
/run-now:
post:
responses:
default:
description: default
schema:
type: object
properties:
run_id: {type: integer, format: int32, description: run_id}
number_in_job: {type: integer, format: int32, description: number_in_job}
summary: Start Databricks Notebook as a Job
description: Start Databricks Notebook as a Job
operationId: run-now
x-ms-visibility: important
parameters:
- {name: Content-Type, in: header, required: true, type: string, default: application/json,
x-ms-visibility: internal}
- {name: Accept, in: header, required: true, type: string, default: application/json,
x-ms-visibility: internal}
- name: body
in: body
required: true
schema:
type: object
properties:
job_id: {type: integer, format: int64, description: job_id, title: ''}
required: [job_id]
definitions: {}
parameters: {}
responses: {}
securityDefinitions:
API Key: {type: apiKey, in: header, name: Authorization}
security:
- API Key: []
tags: []
Here is the actual request as seen in PowerApps monitor that returns a successful 200 code (same url for everyone getting a success):
And here is the actual request sent that returns the 401 error:
As you can see, the request url is the same for both except for that last highlighted string. Can anyone tell me how that is generated from the specified host in the API call definition? Any idea what that may signify?

Uploading multiple file with swagger api documentation and Spring Boot

I want to upload a list of files using swagger api and I can not find a way in which I get the endpoint generated having a list of MultipartFile. Could you please help me? I also searched in the swagger documentation without any luck. For now I have the following swagger config:
x-swagger-router-controller: attachments
post:
operationId: saveFiles
summary: saves the uploaded files
tags:
- files
consumes:
- multipart/form-data
produces:
- application/json
parameters:
- name: files
in: formData
type: array
items:
type: file
description: Files to be uploaded
required: true
- name: type
type: array
items:
type: string
description: File types
in: path
required: true
responses:
201:
description: Saved files
schema:
$ref: '#/definitions/CreatedFilesResponse'
415:
description: Unsupported media type
schema:
$ref: '#/definitions/ErrorResponse'
default:
description: Error
schema:
$ref: '#/definitions/ErrorResponse'
this code generates the following spring endpoint
public ResponseEntity<CreatedAttachmentsResponse> createFile(List<File> list, List<String> list1) {
return null;
}

Schema error at paths should NOT have additional properties in SWAGGER

Please help me to solve this issue
paths: 'sepa/sct/{OriginatorAccount}':
post:
tags:
- SCT Initiation
summary: SCT Initiation
description: ''
operationId: doSEPASCTInit
parameters:
- name: OriginatorAccount
in: path
description: Originator Account
required: true
type: string
- in: body
description: Input Content
name: body
required: false
schema:
$ref: '#/definitions/MandateInfo'
responses:
'200':
description: successful operation
schema:
$ref: '#/definitions/MandateInfo'
'400':
description: Operation failed
default:
description: Alert details added successfully.
Error:
Schema error at paths should NOT have additional properties
additionalProperty: sepa/sct/{OriginatorAccount}
Endpoint paths must begin with a forward slash /:
/sepa/sct/{OriginatorAccount}

OpenAPI-Specification 2.0 a post with body AND header

I want to send a object in a post but with a api key.
How can I describe this in OpenAPI-Specification 2.0?
I tried this (a subset in yaml):
paths:
/eau:
post:
tags:
- Pets
summary: Send a pet
description: 'Send a pet'
operationId: sendapet
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: pet
description: Send a pet
required: true
schema:
$ref: '#/definitions/pet'
- in: header
name: api_key
But at
- in: header
name: api_key
I get the following error:
Schema error at paths['/pet'].post.parameters[1].in
should be equal to one of the allowed values
allowedValues: body
Jump to line 36
Schema error at paths['/pet'].post.parameters[1]
should match exactly one schema in oneOf
Jump to line 36
Schema error at paths['/pet'].post.parameters[1]
should NOT have additional properties
additionalProperty: in, name
Jump to line 36
The error occurs because the header parameter is missing type.
However, API keys are related to authentication/authorization, so they should be described using the securityDefinitions and security keywords instead of a header parameter:
securityDefinitions:
apiKey:
type: apiKey
in: header
name: api_key
security:
- apiKey: []
More info: API Keys

Not a valid parameter definition

/cancel:
post:
description: ''
summary: Cancel
operationId: Cancel
produces:
- application/json
parameters:
- name: Body
in: body
required: true
description: ''
schema:
$ref: '#/definitions/CancelRequest'
- name: Authorization
in: header
required: true
description: ''
schema:
$ref: '#/definitions/Authorization'
- name: Content-Type
in: header
required: true
type: string
description: ''
Here's the snippet. It says that on the line with $ref: '#/definitions/CancelRequest' there is a wrong parameter definition. What might be the problem?
The error is probably misleading, the problem is with other parameters:
The Content-Type header should be defined using the consumes keyword rather than a parameter:
/cancel:
post:
consumes:
- application/json
- application/xml
Header parameters require a type (not a schema) and the type must be a simple type and cannot be a $ref. So it should be:
- name: Authorization
in: header
required: true
description: ''
type: string # <-------
However, in case of the Authorization header you should probably use a security definition instead. For example, if your API uses Basic authentication:
securityDefinitions:
BasicAuth:
type: basic
paths:
/cancel:
post:
security:
- BasicAuth: []

Resources