Azure API Management ignores formData input parameters - servicestack

I have an API built using ServiceStack which implements the Swagger UI and OpenAPI 2.0 specification.
I have several POST methods that use formData inputs and these show in the Swagger UI as individual input textboxes as shown below:
The OpenApi output that Swagger generates looks like this for the input parameters:
'/api/{Version}/apimethod':
post:
tags:
- API
summary: Get a values from an API.
description: Notes here
operationId: UniqueOperationId
consumes:
- application/x-www-form-urlencoded
produces:
- application/json
parameters:
- name: Field1
in: formData
description: Field1
type: number
format: double
required: false
x-nullable: false
- name: Field2
in: formData
description: Field2
type: integer
format: int32
required: false
x-nullable: false
- name: Field3
in: formData
description: Field3
type: integer
format: int32
required: false
x-nullable: false
- name: Field4
in: formData
description: Field4
type: integer
format: int32
required: false
x-nullable: false
- name: Field5
in: formData
description: Field5
type: number
format: double
required: false
x-nullable: false
- name: Field6
in: formData
description: Field6
type: integer
format: int32
required: false
x-nullable: false
- name: Field7
in: formData
description: Field7
type: integer
format: int32
required: false
x-nullable: false
- name: Field8
in: formData
description: Field8
type: integer
format: int32
required: true
x-nullable: false
- name: Version
in: path
description: Version of the API to call
type: integer
format: int32
required: true
x-nullable: false
responses:
'200':
description: Success
schema:
$ref: '#/definitions/GetApiMethodResponse'
'400':
description: Your request was not understood
schema:
$ref: '#/definitions/GetApiMethodResponse'
'500':
description: 'Oops, something broke'
schema:
$ref: '#/definitions/GetApiMethodResponse'
deprecated: false
parameters:
- $ref: '#/parameters/Accept'
If I import the OpenAPI specification into the Azure API Management service to create an new API facade it ignores the formData inputs.
I was expecting that it would list all of the individual inputs and their descriptions in the Azure API Management portal just like the Swagger UI does.
Am I doing something wrong or does the Azure API Management service not list individual formData input parameters the same as the Swagger UI?
My API methods do have alot of parameters and its not very helpful to the end users of the Azure API Management portal to have to fill in a JSON payload which has no descriptions as to what each property on the JSON payload does.

According to your description, I assume your purpose is importing OpenAPI specification into the Azure API Management service and keeping the parameter description in the apim page.
I find that 'post' request can add query parameter but 'get' request can't. After adding some parameters, I get following view. I added 3 parameters, I added description of each parameter but none of them showed in this page.
After that, I exported the api and I got a file named hello.openapi.yaml, here is the detail. I can modify the parameters in this file and then import it in an Api instance.
openapi: 3.0.1
info:
title: hello
description: ''
version: '1.0'
servers:
- url: http://tinyapim.azure-api.net/index
paths:
/hello:
get:
summary: hello
operationId: hello
responses:
'200':
description:
/getJsonObject:
get:
summary: getJsonObject
operationId: getjsonobject
responses:
'200':
description:
/sendpost:
post:
summary: sendPost
operationId: sendpost
parameters:
- name: userName
in: query
description: description1
schema:
enum:
- hello
type: string
- name: userId
in: query
description: required param
required: true
schema:
type: ''
- name: age
in: query
schema:
type: int
responses:
'200':
description:
components:
securitySchemes:
apiKeyHeader:
type: apiKey
name: Ocp-Apim-Subscription-Key
in: header
apiKeyQuery:
type: apiKey
name: subscription-key
in: query
security:
- apiKeyHeader: [ ]
- apiKeyQuery: [ ]
I think these are all Apim can do on your case. Wish it would help.

Related

NestJS: Mongoose timestamp properties in generated OpenAPI spec

I'm using #Schema({ timestamps: true }) to add createdAt & updatedAt to my records and returning these with the response. But seems the OpenAPI spec getting generated by the NestJs's Swagger plugin is not adding the createdAt or updatedAt. How can I get these two added to the generated OpenAPI spec.
openapi: 3.0.0
paths:
/participants/{participantId}:
get:
operationId: ParticipantController_findOne
parameters:
- name: participantId
required: true
in: path
schema:
type: string
responses:
'200':
description: The participant
content:
application/json:
schema:
$ref: '#/components/schemas/Participant'
components:
schemas:
Participant:
type: object
properties:
name:
type: string
description:
type: string
participantId:
type: string
required:
- name
- description
- participantId
My controller looks like this
#ApiOkResponse({
description: 'Get a participant',
type: Participant,
})
#Get(':participantId')
findOne(
#Param('participantId') participantId: string,
): Promise <Participant> {
return this.participantService.findOne(participantId);
}
My Mongoose schema looks like this,
#Schema({ timestamps: true })
export class Participant {
#Prop()
#ApiProperty()
participantId: string;
#Prop()
#ApiProperty()
name: string;
#Prop()
#ApiProperty()
description: string;
}
export const ParticipantSchema = SchemaFactory.createForClass(Participant);
My response looks like this,
{
"name": "Participant One",
"description": "The particicpant one",
"participantId": "participant-001",
"createdAt": "2022-10-14T20:00:52.778Z", // Added automatically by the `timestamps: true`
"updatedAt": "2022-10-14T20:04:31.081Z",// Added automatically by the `timestamps: true`
}

How generate an API documentation for /api/login_check and /api/token/refresh with NelmioApiDocBundle(4.x)

I found a way how generate an API documentation for /api/login_check and /api/token/refresh with NelmioApiDocBundle(4.x).
My project is an API REST with Symfony 5.1.
There is my route.yaml :
api_login_check:
path: /api/login_check
methods: POST
gesdinet_jwt_refresh_token:
path: /api/token/refresh
controller: gesdinet.jwtrefreshtoken::refresh
methods: POST`
and my config/packages/nelmio_api_doc.yaml:
nelmio_api_doc:
models: { use_jms: false }
documentation:
info:
title: BileMoAPI
description: This is an awesome API REST for BileMo!
version: 1.0.0
components:
securitySchemes:
Bearer:
type: http
scheme: bearer
bearerFormat: JWT
in: header
security:
- Bearer: []
paths:
/api/login_check:
post:
tags:
- Login
summary: Login into the api.
requestBody:
content:
application/json:
schema:
properties:
username:
type: string
password:
type: string
type: object
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
token:
type: string
refresh_token:
type: string
'401':
description: Invalid credentials
'400':
description: Invalid JSON.
security: []
/api/token/refresh:
post:
tags:
- Login
summary: Login into the api by refresh token.
requestBody:
content:
application/json:
schema:
properties:
refresh_token:
type: string
type: object
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
token:
type: string
refresh_token:
type: string
'401':
description: An authentication exception occurred.
security: []
areas: # to filter documented areas
path_patterns:
- ^/api(?!(/doc|/doc.json|/token/refresh)$)
#host_patterns:
# - ^/api
And the screenshot of /api/doc :
the screenshot of /api/doc
I hope a can help someone :)
The answer is in the question (Sorry, I'm novice on Stack)

Swagger validation error- request.path should NOT have additional properties

This has to do with all paths that have the "user_id" parameter in them (i.e- all but postUser). When I test these endpoints with Postman I'm getting a 400 with a message of "request.path should NOT have
additional properties".
I am using a package as a swagger validator middleware in my routes in the following manner. For example:
router.get('/:userId', swaggerValidator.validate, contextExtractor, getUserById);
Where the swagger validation comes first, then 2 other middlewares.
The package can be found here: https://www.npmjs.com/package/openapi-validator-middleware
If I drop the validator middleware all's good and the code works as expected.
See the swagger file below:
swagger: "2.0"
info:
description: "This is an external Users service API. It manages any user info in the systems, including its personal data, address and additional needed values, all in favour of maintaining the updated and relevant data which is either business-related or provided when a user requests any action in the system."
version: "1.0.0"
title: "Users Micro Service"
basePath: "/v1"
tags:
- name: "User Details"
description: "A user's data and info, supporting CRUD operations"
- name: "User Addresses"
description: "All the addresses data of a user"
- name: "User Address"
description: "A user's single address data"
schemes:
- "https"
- "http"
consumes:
- "application/json; charset=utf-8"
produces:
- "application/json; charset=utf-8"
paths:
'/users':
post:
tags:
- "User Details"
summary: "Create a new user in the system"
operationId: "postUser"
parameters:
- $ref: "#/parameters/company_user_id"
- $ref: "#/parameters/company_request_id"
- in: "body"
name: "User Request"
description: "The user's data to be stored"
required: true
schema:
$ref: "#/definitions/user_request"
responses:
201:
description: "Successful Operation"
schema:
$ref: "#/definitions/user_resource"
400:
description: "Bad Request"
schema:
$ref: "#/definitions/error"
409:
description: "Conflict - email already exists"
schema:
$ref: "#/definitions/error"
500:
description: "Internal Error"
schema:
$ref: "#/definitions/error"
'/users/:user_id':
get:
tags:
- "User Details"
summary: "Get the user's data by its Id"
operationId: "getUserById"
parameters:
- $ref: "#/parameters/company_user_id"
- $ref: "#/parameters/company_request_id"
- $ref: "#/parameters/user_id"
responses:
200:
description: "Successful operation"
schema:
$ref: "#/definitions/user_resource"
400:
description: "Bad Request"
schema:
$ref: "#/definitions/error"
404:
description: "User was not found"
schema:
$ref: "#/definitions/error"
500:
description: "Internal Error"
schema:
$ref: "#/definitions/error"
patch:
tags:
- "User Details"
summary: "Modify an existing user's data"
operationId: "patchUserById"
parameters:
- $ref: "#/parameters/company_user_id"
- $ref: "#/parameters/company_request_id"
- $ref: "#/parameters/user_id"
- in: "body"
name: "User data"
description: "The user's data to be modified"
required: true
schema:
$ref: "#/definitions/user_patch_request"
responses:
200:
description: "Successful Operation"
schema:
$ref: "#/definitions/user_resource"
400:
description: "Bad Request"
schema:
$ref: "#/definitions/error"
404:
description: "Not Found"
schema:
$ref: "#/definitions/error"
500:
description: "Internal Error"
schema:
$ref: "#/definitions/error"
put:
tags:
- "User Details"
summary: "Modify an existing user's data by overriding it"
operationId: "putUserById"
parameters:
- $ref: "#/parameters/company_user_id"
- $ref: "#/parameters/company_request_id"
- $ref: "#/parameters/user_id"
- in: "body"
name: "User data"
description: "The user's data to be modified"
schema:
$ref: "#/definitions/user_put_request"
responses:
200:
description: "Successful Operation"
schema:
$ref: "#/definitions/user_resource"
400:
description: "Bad Request"
schema:
$ref: "#/definitions/error"
404:
description: "Not Found"
schema:
$ref: "#/definitions/error"
500:
description: "Internal Error"
schema:
$ref: "#/definitions/error"
'/users/:user_id/addresses':
post:
tags:
- "User Address"
summary: "Create a new address for a user and store it in the database"
operationId: "postAddress"
parameters:
- $ref: "#/parameters/company_user_id"
- $ref: "#/parameters/company_request_id"
- $ref: "#/parameters/user_id"
- in: "body"
name: "Address Request"
description: "The address data to be stored"
required: true
schema:
$ref: "#/definitions/put_user_address_request"
responses:
201:
description: "Successful Operation"
schema:
$ref: "#/definitions/user_address_resource"
400:
description: "Bad Request"
schema:
$ref: "#/definitions/error"
500:
description: "Internal Error"
schema:
$ref: "#/definitions/error"
get:
tags:
- "User Addresses"
summary: "Get all addresses of a user by its id"
operationId: "getAddresses"
parameters:
- $ref: "#/parameters/company_user_id"
- $ref: "#/parameters/company_request_id"
- $ref: "#/parameters/user_id"
responses:
200:
description: "Successful Operation"
schema:
type: "array"
items:
$ref: "#/definitions/user_address_resource"
400:
description: "Bad Request"
schema:
$ref: "#/definitions/error"
404:
description: "User not found"
schema:
$ref: "#/definitions/error"
500:
description: "Internal Error"
schema:
$ref: "#/definitions/error"
'/users/:user_id/addresses/:address_id':
get:
tags:
- "User Address"
summary: "Get a user's address by its Id"
operationId: "getAddressById"
parameters:
- $ref: "#/parameters/company_user_id"
- $ref: "#/parameters/company_request_id"
- $ref: "#/parameters/user_id"
- $ref: "#/parameters/address_id"
responses:
200:
description: "Successful Operation"
schema:
$ref: "#/definitions/user_address_resource"
400:
description: "Bad Request"
schema:
$ref: "#/definitions/error"
404:
description: "Not Found"
schema:
$ref: "#/definitions/error"
500:
description: "Internal Error"
schema:
$ref: "#/definitions/error"
put:
tags:
- "User Address"
summary: "Modify a user's existing address data by overriding it"
operationId: "putAddressById"
parameters:
- $ref: "#/parameters/company_user_id"
- $ref: "#/parameters/company_request_id"
- $ref: "#/parameters/user_id"
- $ref: "#/parameters/address_id"
- in: "body"
name: "Address"
description: "The address's data to be modified"
schema:
$ref: "#/definitions/put_user_address_request"
responses:
200:
description: "Successful Operation"
schema:
$ref: "#/definitions/user_address_resource"
400:
description: "Bad Request"
schema:
$ref: "#/definitions/error"
404:
description: "Not Found"
schema:
$ref: "#/definitions/error"
500:
description: "Internal Error"
schema:
$ref: "#/definitions/error"
patch:
tags:
- "User Address"
summary: "Add or modify to an existing user's address data"
operationId: "patchAddressById"
parameters:
- $ref: "#/parameters/company_user_id"
- $ref: "#/parameters/company_request_id"
- $ref: "#/parameters/user_id"
- $ref: "#/parameters/address_id"
- in: "body"
name: "Address"
description: "The address data to be modified"
schema:
$ref: "#/definitions/patch_user_address_request"
responses:
200:
description: "Successful Operation"
schema:
$ref: "#/definitions/user_address_resource"
400:
description: "Bad Request"
schema:
$ref: "#/definitions/error"
404:
description: "Not Found"
schema:
$ref: "#/definitions/error"
500:
description: "Internal Error"
schema:
$ref: "#/definitions/error"
delete:
tags:
- "User Address"
summary: "Deletes a user's address by its Id"
operationId: "deleteAddressById"
produces:
- "text/plain; charset=utf-8"
parameters:
- $ref: "#/parameters/company_user_id"
- $ref: "#/parameters/company_request_id"
- $ref: "#/parameters/user_id"
- $ref: "#/parameters/address_id"
responses:
204:
description: "Successful Operation - No content"
400:
description: "Bad Request"
schema:
$ref: "#/definitions/error"
404:
description: "Not Found"
schema:
$ref: "#/definitions/error"
500:
description: "Internal Error"
schema:
$ref: "#/definitions/error"
definitions:
user_request:
type: "object"
description: "User request body"
required:
- email_address
- terms_accepted
- first_name
- last_name
properties:
email_address:
type: "string"
description: "The user's email address (unique)"
first_name:
type: "string"
description: "The user's first name"
last_name:
type: "string"
description: "The user's last name"
marketing_opt_in_accepted:
type: "boolean"
description: "Boolean to determine if the user has opted in for marketing"
default: false
terms_accepted:
type: "boolean"
description: "Boolean to determine if the user has accepted the site's terms"
phone_number:
type: "string"
description: "The user's phone number"
additional_values:
type: "object"
x-example: {
"key1" : "value1",
"key2" : "value2"
}
user_put_request:
required:
- email_address
- first_name
- last_name
type: "object"
properties:
email_address:
type: "string"
description: "The user's email address"
first_name:
type: "string"
description: "The user's first name"
last_name:
type: "string"
description: "The user's last name"
marketing_opt_in_accepted:
type: "boolean"
description: "Boolean to determine if the user has opted in for marketing (default: false)"
default: false
phone_number:
type: "string"
description: "The user's phone number"
additional_values:
type: "object"
x-example: {
"key1" : "value1",
"key2" : "value2"
}
user_patch_request:
type: "object"
properties:
email_address:
type: "string"
description: "The user's email address"
first_name:
type: "string"
description: "The user's first name"
last_name:
type: "string"
description: "The user's last name"
marketing_opt_in_accepted:
type: "boolean"
description: "Boolean to determine if the user has opted in for marketing"
default: false
phone_number:
type: "string"
description: "The user's phone number"
additional_values:
type: "object"
x-example: {
"key1": "value1",
"key2": "value2"
}
user_resource:
type: "object"
allOf: [$ref: '#/definitions/user_request', $ref: '#/definitions/updatable_object_metadata']
required:
- date_terms_accepted
properties:
date_terms_accepted:
type: "string"
format: "date-time"
description: "Time stamp of when the user has accepted the site's terms"
put_user_address_request:
required:
- address_line_1
- city
- postal_code
- country_code
properties:
nickname:
type: "string"
description: "A human-readable nickname for the address"
x-example: "HOME"
address_line_1:
type: "string"
description: "A text line containing street name and number"
x-example: "3 Florentin Street"
address_line_2:
type: "string"
description: "A text line containing apartment number, floor, entrance, etc."
x-example: "372A, 7th floor"
address_line_3:
type: "string"
description: "A text line containing additional delivery instructions"
x-example: "Please knock on the door instead of ringing the bell"
country_code:
type: "string"
description: "3-letter alpha-code for a country (capital letters only)"
x-example: "GBR"
state_province:
type: "string"
description: "The state or province in which the address is in"
x-example: "Yorkshire"
city:
type: "string"
description: "The city in which the address is in"
x-example: "London"
postal_code:
type: "string"
description: "The address' zipcode"
x-example: "EC1A 1BB"
address_type:
type: "string"
description: "The type of which the address belongs to"
enum: ["RESIDENTIAL", "OFFICE", "HOTEL", "BUSINESS"]
x-example: "OFFICE"
patch_user_address_request:
type: "object"
properties:
nickname:
type: "string"
description: "A human-readable nickname for the address"
x-example: "HOME"
address_line_1:
type: "string"
description: "A text line containing street name and number"
x-example: "3 Florentin Street"
address_line_2:
type: "string"
description: "A text line containing apartment number, floor, entrance, etc."
x-example: "372A, 7th floor"
address_line_3:
type: "string"
description: "A text line containing additional delivery instructions"
x-example: "Please knock on door instread of ringing bell"
country_code:
type: "string"
description: "3-letter alpha-code for a country (capital letters only)"
x-example: "GBR"
state_province:
type: "string"
description: "The state or province in which the address is in"
x-example: "Yorkshire"
city:
type: "string"
description: "The city in which the address is in"
x-example: "London"
postal_code:
type: "string"
description: "The address' zipcode"
x-example: "EC1A 1BB"
address_type:
type: "string"
description: "The type of which the address belongs to"
enum: ["RESIDENTIAL", "OFFICE", "HOTEL", "BUSINESS"]
x-example: "OFFICE"
user_address_resource:
type: "object"
required:
- id
- address_line_1
- address_created
- address_updated
- city
- country_code
- postal_code
properties:
id:
type: "string"
format: "uuid"
description: "The address Id"
x-example: "23cfeebf-45ef-4446-9f2f-017894fc806e"
nickname:
type: "string"
description: "A human-readable nickname for the address"
x-example: "HOME"
address_line_1:
type: "string"
description: "A text line containing street name and number"
x-example: "3 Florentin Street"
address_line_2:
type: "string"
description: "A text line containing apartment number, floor, entrance, etc."
x-example: "372A, 7th floor"
address_line_3:
type: "string"
description: "A text line containing additional delivery instructions"
x-example: "Please knock on door instread of ringing bell"
country_code:
type: "string"
description: "3-letter alpha-code for a country (capital letters only)"
x-example: "GBR"
state_province:
type: "string"
description: "The state or province in which the address is in"
x-example: "Yorkshire"
city:
type: "string"
description: "The city in which the address is in"
x-example: "London"
postal_code:
type: "string"
description: "The address' zipcode"
x-example: "EC1A 1BB"
address_type:
type: "string"
description: "The type of which the address belongs to"
enum: ["RESIDENTIAL", "OFFICE", "HOTEL", "BUSINESS"]
x-example: "OFFICE"
address_created:
type: "string"
format: "date-time"
description: "Timestamp of when the address was created"
x-example: "2017-08-19 12:17:55 -0400"
address_updated:
type: "string"
format: "date-time"
description: "Timestamp of when the address was updated"
x-example: "2017-08-19 12:17:55 -0400"
user_id_created:
type: "string"
format: "uuid"
description: "The user id which created the address"
x-example: "1df65272-a44e-4b8c-887d-b645ec9136a0"
user_id_updated:
type: "string"
format: "uuid"
description: "The user id which last updated the address"
x-example: "1df65272-a44e-4b8c-887d-b645ec9136a0"
object_metadata:
type: "object"
required:
- id
- created_time
- user_id_created
- updated_time
properties:
id:
type: "string"
format: "uuid"
created_time:
type: "string"
format: "date-time"
user_id_created:
type: "string"
format: "uuid"
updated_time:
type: "string"
format: "date-time"
updatable_object_metadata:
type: "object"
allOf:
- $ref: '#/definitions/object_metadata'
required:
- user_id_updated
properties:
user_id_updated:
type: "string"
format: "uuid"
error:
type: "object"
required:
- "message"
properties:
message:
type: "string"
description: "The error's message"
more_info:
type: "string"
description: "More info if it exists"
parameters:
company_user_id:
name: "x-company-user-id"
in: "header"
description: "The User Id"
required: true
type: "string"
format: "uuid"
x-example: "15325c58-a41a-4105-bae1-99fa3a8bedc7"
company_request_id:
name: "x-company-request-id"
in: "header"
description: "The Request Id"
required: true
type: "string"
format: "uuid"
x-example: "5134366e-ce9e-42ea-921b-ebe11257a773"
user_id:
name: "user_id"
in: "path"
description: "The user's Id"
required: true
type: "string"
format: "uuid"
x-example: "fc1e2015-f408-465a-af97-6621a3754764"
address_id:
name: "address_id"
in: "path"
required: true
type: "string"
format: "uuid"
x-example: "08ed91c3-ce96-4c93-b75a-5a0c6eb8d13c"
Your example uses the :param notation for path parameters, which OpenAPI does not support. OpenAPI uses the {param} notation. You need to change your API definition to use {param} instead of :param.
Incorrect:
paths:
'/users':
...
'/users/:user_id':
...
'/users/:user_id/addresses':
...
'/users/:user_id/addresses/:address_id':
...
Correct:
paths:
'/users':
...
'/users/{user_id}':
...
'/users/{user_id}/addresses':
...
'/users/{user_id}/addresses/{address_id}':
...

What is the correct way test the file upload through swagger-client?

I need to write a valid test of a file upload through swagger client but I can not figure out what I'm doing wrong or possible solutions
const requestBody = {
name: 'USUÁRIO TESTE',
cpf: 'PROCESSO DE TESTE/DEPLOY KAER-MORHEN',
email: 'POR FAVOR IGNORE ESTE E-MAIL',
phone: 'OBRIGADO',
id: 'cj2c3rtea00010epfu0sfdhf7',
back: tmp.fileSync({ prefix: 'document-', postfix: '.jpg' }).name
}
return client.apis.documents.sendDocumentsEmail(undefined, {
requestBody
})
.should.be.fulfilled()
.then(({ status, body }) => {
status.should.be.eql(200)
body.should.be.Object()
})
I'm also using Multer as middleware, and when I send the tmp file or creating a file with fs it doesn't get recognized and the attribute ends up beeing treated as a string.
What would be the simplest way to send a valid multipart/form-data with a valid file using swagger-client?
/documents/upload:
x-middlewares:
- "multer"
post:
tags:
- "documents"
- "kaermorhen"
summary: "Upload documents"
x-swagger-router-controller: "document.controller"
operationId: "sendDocumentsEmail"
requestBody:
description: "Documents upload"
required: true
x-name: "body"
content:
multipart/form-data:
schema:
type: "object"
required:
- "id"
properties:
id:
type: "string"
name:
type: "string"
cpf:
type: "string"
email:
type: "string"
phone:
type: "string"
front:
type: string
format: binary
back:
type: string
format: binary
residence:
type: string
format: binary

Swagger auto generate documentation yaml format?

There is sequelize auto where in you can generate generate models for SequelizeJS via the command line. I wanted to know if there is a way to auto generate api swagger documentaion in .yaml fromat based from my database using command line. Thanks . your help would really be appreaciated.
swagger api documentaion , is there a way to auto generate it instead og typing each CRUD from my database which is a hassle. Thanks
swagger: "2.0"
info:
version: 1.0.0
title: myApp1.0
description: my Application 1.0
basePath: /api/v1
tags:
- name: Examples
description: Simple example endpoints
- name: Products
description: Simple products endpoints
- name: Countries
description: Simple countries endpoints
- name: Users
description: Simple Users endpoints
- name: Specification
description: The swagger API specification
consumes:
- application/x-www-form-urlencoded
- application/json
produces:
- application/json
definitions:
ExampleBody:
type: object
title: example
required:
- name
properties:
name:
type: string
description: The example name
ProductsBody:
type: object
title: products
required:
- name
properties:
name:
type: string
description: The products name
CountriesBody:
type: object
title: countries
required:
- name
- sortname
properties:
name:
type: string
description: The countries name
sortname:
type: string
description: The countries sortname
UsersBody:
type: object
title: users
required:
- user_id
- firstname
- lastname
- about
- username
- email
- password
- last_login
- status
properties:
name:
type: string
description: The users firstname
sortname:
type: string
description: The users lastname
paths:
/examples:
get:
tags:
- Examples
description: Fetch all examples
responses:
200:
description: Returns all examples
post:
tags:
- Examples
description: Create a new example
parameters:
- name: example
in: body
description: number of items to skip
required: true
schema:
$ref: "#/definitions/ExampleBody"
responses:
200:
description: Returns all examples
/examples/{id}:
get:
tags:
- Examples
parameters:
- name: id
in: path
required: true
description: The id of the entity to retrieve
type: integer
responses:
200:
description: Return the example with the specified id
404:
description: Example not
/products:
get:
tags:
- Products
description: Fetch all products
parameters:
- name: offset
in: query
required: true
description: The offset of the pagination
type: integer
- name: limit
in: query
required: true
description: The limit of the pagination
type: integer
responses:
200:
description: "successful operation"
#security:
#- api_key: []
post:
tags:
- Products
description: Create a new example
parameters:
- name: example
in: body
description: number of items to skip
required: true
schema:
$ref: "#/definitions/ProductsBody"
responses:
200:
description: Returns all products
security:
- api_key: []
/products/{id}:
get:
tags:
- Products
parameters:
- name: id
in: path
required: true
description: The id of the entity to retrieve
type: integer
responses:
200:
description: Return the products with the specified id
404:
description: Products not
security:
- api_key: []
/countries:
get:
tags:
- Countries
description: Fetch all countries
parameters:
- name: token
in: header
required: false
description: The header token
type: string
- name: offset
in: query
required: false
description: The offset of the pagination
type: integer
- name: limit
in: query
required: false
description: The limit of the pagination
type: integer
responses:
200:
description: "successful operation"
#security:
#- api_key: []
post:
tags:
- Countries
description: Create a new Country
parameters:
- name: token
in: header
required: false
description: The header token
type: string
- name: country
in: body
description: number of items to skip
required: true
schema:
$ref: "#/definitions/CountriesBody"
responses:
200:
description: Create Country
# security:
# - api_key: []
/users:
get:
tags:
- Users
description: Fetch all users
parameters:
- name: token
in: header
required: false
description: The header token
type: string
- name: offset
in: query
required: false
description: The offset of the pagination
type: integer
- name: limit
in: query
required: false
description: The limit of the pagination
type: integer
responses:
200:
description: "successful operation"
post:
tags:
- Users
description: Create New User Accounts
parameters:
- name: Users
in: body
description: number of items to skip
required: true
schema:
$ref: "#/definitions/UsersBody"
responses:
200:
description: Create User Accounts
security:
- api_key: []
/users/{id}:
delete:
tags:
- Users
parameters:
- user_id: id
in: path
required: true
description: The id of the entity to be deleted
type: integer
responses:
200:
description: Returns a successful delete
404:
description: Error
security:
/spec:
get:
tags:
- Specification
responses:
200:
description: Return the API specification
securityDefinitions:
#petstore_auth:
# type: "oauth2"
# authorizationUrl: "http://petstore.swagger.io/oauth/dialog"
# flow: "implicit"
# scopes:
# write:pets: "modify pets in your account"
# read:pets: "read your pets"
api_key:
type: "apiKey"
name: "api_key"
in: "header"

Resources