swagger editor: missingProperty: required - swagger

I am using openapi 3 and got an error:
should have required property 'required'
missingProperty: required
Here is my file:
openapi: 3.0.0
...
- name: count
in: path
description: "count"
schema:
type: boolean
If I add required: false, I got another error saying required can only be true

Path parameters are always required, so they must have required: true.

Related

Swagger codegen overrides query parameter with a header parameter that has the same name

I have a swagger definition that has a query and a header that share the same name:
parameters:
qry_param:
name: appid
in: query
required: true
type: string
hdr_param:
name: appid
in: header
required: false
type: string
...
paths:
'/some/path/here':
post:
parameters:
- $ref: '#/parameters/hdr_param'
- $ref: '#/parameters/qry_param'
When I try to generate a client with swagger-codegen-maven-plugin only request header is generated for this parameter.
What can I do to generate both?

How to define an URL ending with an integer?

The OpenAPI definition below will generate the URL as http://localhost:9200/GetCourse?id=1. How to change the definition to generate the URL as http://localhost:9200/GetCourse/1?
/GetCourse:
get:
summary: Get Courses
description: >
The GetCourse details.
tags:
- Content information
parameters:
- name: id
in: query
description: The ID of the HEI being queried
required: true
type: integer
responses:
'200':
description: An array of courses
schema:
$ref: '#/definitions/Courses'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
Change the parameter location (in) from query to path.
Add /{id} at the end of the path name.
paths:
/GetCourse/{id}: # <----
get:
...
parameters:
- name: id
in: path # <----
description: The ID of the HEI being queried
required: true
type: integer

Serverless-aws-documentation swagger parameters

When I use serverless openapi generate the resulting openapi.yaml contains no parameters
I have tried parameters instead queryParams as well as pathParams
functions:
get:
handler: retransmit/get.get
events:
- http:
path: retransmit/{game_id}/{camera_id}
method: get
cors: true
documentation:
summary: "Fetch frame_id"
description: "Fetch frame_id ranges for given grab_id and camera_id"
queryParams:
- name: "game_id"
description: "app id"
required: true
- name: "camera_id"
description: "user id or 'my'"
required: true
error:
Semantic error at paths./retransmit/{game_id}/{camera_id}
Declared path parameter "game_id" needs to be defined as a path parameter at either the path or operation level
Jump to line 27
Semantic error at paths./retransmit/{game_id}/{camera_id}
Declared path parameter "camera_id" needs to be defined as a path parameter at either the path or operation level
Jump to line 27
Change queryParams to pathParams
functions:
get:
handler: retransmit/get.get
events:
- http:
path: retransmit/{game_id}/{camera_id}
method: get
cors: true
documentation:
summary: "Fetch frame_id"
description: "Fetch frame_id ranges for given grab_id and camera_id"
pathParams:
- name: "game_id"
description: "app id"
required: true
- name: "camera_id"
description: "user id or 'my'"
required: true

Required property per path and method

Consider the following sample specification:
swagger: '2.0'
info:
title: stackoverflow question
version: '1.0'
paths:
/websites:
post:
parameters:
- in: body
name: website
required: true
schema:
$ref: '#/definitions/website'
responses:
201:
description: Website created
/websites/{id}:
patch:
parameters:
- name: 'id'
in: 'path'
type: 'integer'
required: true
- in: body
name: fields
required: true
schema:
$ref: '#/definitions/website'
responses:
200:
description: Website updated
definitions:
website:
type: object
required:
- fieldB
properties:
fieldA:
type: string
readOnly: true
fieldB:
type: string
format: date-time
fieldC:
type: string
format: date-time
The fieldB property is required for both POST and PATCH methods. Is it possible to make it required only for a single path and method without having to specify two different model definitions?
If not, what would be a good solution to achieve this?

Create my own type in Swagger

I Have this YAML code of swagger and I need to create my own type (named MyOwnType).
If I use "MyOwnType" a compilation error occurs.
paths:
/in/total:
get:
summary: My summary.
description: My description.
parameters:
- name: total
in: query
description: Total.
required: true
type: MyOwnType # -- THIS LINE OCCURS ERROR --
format: MyOwnType
responses:
201:
description: Respose
schema:
$ref: '#/definitions/MyOwnType'
definitions:
MyOwnType:
properties:
var:
type: string
description: data.
I created a definition "MyOwnType" and I can use like that: "$ref: '#/definitions/MyOwnType'" in schema.
But how can I use the "MyOwnType" definition on a parameter type?
A query parameter can not have a JSON Schema. If you want to have schema for your parameter you should change in of your parameter to body or formData and use schema key:
swagger: '2.0'
info:
version: 0.0.0
title: '<enter your title>'
paths:
/in/total:
get:
summary: My summary.
description: My description.
parameters:
- name: total
in: body
description: Total.
required: true
schema:
$ref: '#/definitions/MyOwnType'
responses:
201:
description: Respose
schema:
$ref: '#/definitions/MyOwnType'
definitions:
MyOwnType:
properties:
var:
type: string
description: data.

Resources