You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed the README guidelines and created a JSON file after copy-pasting JSON response when hitting http://localhost:3000/apidocs URL. Swagger Editor fails to accept it saying:
Here is ApidocsController:
class ApidocsController < ApplicationController
skip_before_action :authorize_request
include Swagger::Blocks
swagger_root do
key :swagger, '2.0'
info do
key :version, '1.0.0'
key :title, 'Example Project API'
key :description, 'A Swagger Project API that uses a bla-bla-bla project features ' \
'in commliance with the swagger-2.0 specification'
contact do
key :name, 'Fancy API Team'
end
license do
key :name, 'MIT'
end
end
tag do
key :name, 'fancy_project'
key :description, 'Example Project API operations'
externalDocs do
key :description, 'Find more info here'
key :url, 'https://swagger.io'
end
end
key :host, 'https://api-eu.swagger/example-project'
key :basePath, '/v1'
key :consumes, ['application/json']
key :produces, ['application/json']
end
# A list of all classes that have swagger_* declarations.
SWAGGERED_CLASSES = [
V1::LanguagesController,
Language,
ErrorModel,
self,
].freeze
def index
render json: Swagger::Blocks.build_root_json(SWAGGERED_CLASSES)
end
end
Here is V1::LanguagesController code:
module V1
class LanguagesController < ApplicationController
include Swagger::Blocks
before_action :find_language, only: :show
swagger_path '/languages' do
operation :get do
key :summary, 'All Language tags'
key :description, 'Returns all language ISO tags from the system that the user has access to'
key :produces, [
'application/json'
]
key :tags, [
'language'
]
response 200 do
key :description, 'Languages response'
schema do
key :type, :array
items do
key :'$ref', :Language
end
end
end
response :default do
key :description, 'unexpected error'
schema do
key :'$ref', :ErrorModel
end
end
end
end
def index
@languages = Language.all
json_response @languages, :ok
end
...
What am I missing ? Rails 5.2. (API-mode) ruby 2.5.0
The text was updated successfully, but these errors were encountered:
belgoros
changed the title
Fail to import into Swagger Editor - extra comma in generated JSON file
Fails to import into Swagger Editor - extra comma in generated JSON file
Dec 3, 2018
I followed the README guidelines and created a JSON file after copy-pasting JSON response when hitting
http://localhost:3000/apidocs
URL.Swagger Editor fails to accept it saying:
Here is ApidocsController:
Here is V1::LanguagesController code:
What am I missing ?
Rails 5.2.
(API-mode)ruby 2.5.0
You cat find
swagger.json
content in this gist.The text was updated successfully, but these errors were encountered: