From 1a10e3c784684edbefc5b70918b59b8bc1cef7cc Mon Sep 17 00:00:00 2001 From: Runar Ingebrigtsen Date: Sun, 1 Feb 2026 05:29:16 +0100 Subject: [PATCH] api completion --- app/controllers/api/base.rb | 5 +++-- app/controllers/api/entities/entry.rb | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 app/controllers/api/entities/entry.rb diff --git a/app/controllers/api/base.rb b/app/controllers/api/base.rb index bfee9a6..ee14ab4 100644 --- a/app/controllers/api/base.rb +++ b/app/controllers/api/base.rb @@ -1,6 +1,5 @@ require "grape" require "grape-swagger" -require "ostruct" class Api::Base < Grape::API format :json @@ -18,7 +17,9 @@ class Api::Base < Grape::API resource :entries do desc "Return public entries in all languages", - attributes: OpenStruct.new(success: nil, produces: nil) + is_array: true, + success: Api::Entities::Entry, + produces: ["application/json"] params do optional :since, type: String, diff --git a/app/controllers/api/entities/entry.rb b/app/controllers/api/entities/entry.rb new file mode 100644 index 0000000..03e8968 --- /dev/null +++ b/app/controllers/api/entities/entry.rb @@ -0,0 +1,15 @@ +module Api + module Entities + class Entry < Grape::Entity + expose :id, documentation: { type: "integer", format: "int64", desc: "Entry ID." } + expose :category, documentation: { type: "string", desc: "Category label." } + expose :fi, documentation: { type: "string", desc: "Finnish term/definition.", allow_nil: true } + expose :en, documentation: { type: "string", desc: "English term/definition.", allow_nil: true } + expose :sv, documentation: { type: "string", desc: "Swedish term/definition.", allow_nil: true } + expose :no, documentation: { type: "string", desc: "Norwegian term/definition.", allow_nil: true } + expose :ru, documentation: { type: "string", desc: "Russian term/definition.", allow_nil: true } + expose :de, documentation: { type: "string", desc: "German term/definition.", allow_nil: true } + expose :updated_at, documentation: { type: "string", format: "date-time", desc: "Last update timestamp (ISO8601)." } + end + end +end