Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rubyhcm/demo-swagger
Demo swagger - open api
https://github.com/rubyhcm/demo-swagger
openapi rails ruby swagger
Last synced: 26 days ago
JSON representation
Demo swagger - open api
- Host: GitHub
- URL: https://github.com/rubyhcm/demo-swagger
- Owner: rubyhcm
- Created: 2023-11-02T10:50:29.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-01-04T15:41:41.000Z (11 months ago)
- Last Synced: 2024-10-03T23:22:24.099Z (about 1 month ago)
- Topics: openapi, rails, ruby, swagger
- Language: Ruby
- Homepage: https://github.com/rubyhcm/demo-swagger
- Size: 42 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Follow these step:
#### Add to Gemfile
gem 'rspec-rails'
gem 'rswag'#### Run
rails g rspec:install
rails g rswag:install
#### Run to generate the Swagger JSON file(s)
rake rswag:specs:swaggerize
#### Start
rails s and result at http://localhost:3000/api-docs/index.html
#### You can add more http request at swagger.yaml such as:
```ruby
---
openapi: 3.0.1
info:
title: API V1
version: v1
paths:
"/api/v1/pets":
post:
summary: create pet
tags:
- Pets
parameters: []
responses:
"201":
description: pet created
"422":
description: invalid request
"200":
description: successful
requestBody:
content:
application/json:
schema:
type: object
properties:
name:
type: string
photo_url:
type: string
status:
type: string
required:
- name
- status
application/xml:
schema:
type: object
properties:
name:
type: string
photo_url:
type: string
status:
type: string
required:
- name
- status
get:
summary: list pets
responses:
"200":
description: successful
"/api/v1/pets/{id}":
get:
summary: show pet
tags:
- Pets
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
"200":
description: successful
"404":
description: pet not found
parameters:
- name: id
in: path
description: id
required: true
schema:
type: stringpatch: # Sử dụng phương thức PATCH thay thế PUT
summary: partially update pet
tags:
- Pets
parameters:
- name: id
in: path
description: ID of the pet to be updated
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
pet:
type: object
properties:
name:
type: string
status:
type: string
required:
- name
- status
responses:
"200":
description: successfullput:
summary: update pet
tags:
- Pets
parameters:
- name: id
in: path
description: ID of the pet to be updated
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
pet:
type: object
properties:
name:
type: string
status:
type: string
required:
- name
- status
responses:
"200":
description: successfuldelete:
summary: delete pet
responses:
"200":
description: successful
servers:
- url: http://{defaultHost}
variables:
defaultHost:
default: localhost:3000```
#### Editor Online
https://editor.swagger.io/