Class: RivetCms::ApiDocsController

Inherits:
ApplicationController show all
Includes:
InertiaProps
Defined in:
app/controllers/rivet_cms/api_docs_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/rivet_cms/api_docs_controller.rb', line 9

def show
  content_types = permitted_types

  render inertia: "Api/Index", props: {
    base_url: api_base_url,
    public_api: RivetCms.public_api,
    content_types: content_types.map { |ct| api_reference_props(ct) },
    doc_paths: { openapi: api_openapi_path, tokens: api_tokens_path }
  }
end

#specObject



20
21
22
23
24
# File 'app/controllers/rivet_cms/api_docs_controller.rb', line 20

def spec
  generator = OpenApiGenerator.new(Current.organization, base_url: api_base_url, content_types: permitted_types,
                                   components: permitted(Current.organization.components, :read, :schema))
  send_data JSON.pretty_generate(generator.as_json), type: :json, disposition: "attachment", filename: "openapi.json"
end