openapi: 3.0.0
info:
title: Sample API
description: API documentation example
version: 1.0.0
servers:
- url: 'https://api.example.com/v1'
paths:
/users:
get:
summary: Get a list of users
responses:
'200':
description: A JSON array of user names
content:
application/json:
schema:
type: object
properties:
name:
type: string
age:
type: integer
default: 25
swagger: '2.0'
info:
title: Sample API
description: API documentation example
version: '1.0'
host: 'api.example.com'
basePath: '/v1'
schemes:
- https
paths:
/users:
get:
summary: Get a list of users
responses:
200:
description: A JSON array of user names
schema:
type: object
properties:
name:
type: string
age:
type: integer
default: 25
swagger: '2.0'
info:
title: Sample API
version: '1.0'
host: 'api.example.com'
basePath: '/v1'
schemes:
- https
securityDefinitions:
APIKeyAuth:
type: apiKey
in: header
name: Authorization
paths:
/users:
get:
summary: Get a list of users
security:
- APIKeyAuth: []
responses:
200:
description: A list of users
schema:
type: array
items:
type: object
properties:
name:
type: string
age:
type: integer
/public-info:
get:
summary: Get public information
responses:
200:
description: Public information, no need for security
openapi: 3.0.0
info:
title: Sample API
version: 1.0.0
servers:
- url: 'https://api.example.com/v1'
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
paths:
/data:
get:
summary: Get data which may include sensitive content if authorized
security:
- BearerAuth: []
- {} # This indicates the endpoint can also be accessed without any authorization
responses:
'200':
description: Successfully retrieved data
content:
application/json:
schema:
type: object
properties:
data:
type: string
privateData:
type: string
description: This field is included only if authorized.
swagger: '2.0'
info:
title: Sample API
version: '1.0'
host: 'api.example.com'
basePath: '/v1'
schemes:
- https
securityDefinitions:
APIKeyAuth:
type: apiKey
in: header
name: Authorization
paths:
/data:
get:
summary: Get data which may include sensitive content if authorized
security:
- APIKeyAuth: []
- {}
responses:
200:
description: Successfully retrieved data
schema:
type: object
properties:
data:
type: string
privateData:
type: string
description: This field is included only if authorized.
openapi: 3.0.0
info:
title: Sample API
version: 1.0.0
servers:
- url: 'https://api.example.com/v1'
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
paths:
/data:
get:
summary: Retrieve data which may include additional sensitive content if authorized
description: >
This endpoint returns basic data that is accessible without
authorization. If an authorization token is provided,
additional detailed information might be returned.
security:
- BearerAuth: []
responses:
'200':
description: A JSON object of basic data, with additional details if authorized
content:
application/json:
schema:
type: object
properties:
basicInfo:
type: string
detailedInfo:
type: string
nullable: true # This indicates that the detailedInfo can be null if unauthorized