Skip to content

feat(dictionary): add raw option for entry APIs for raw HTTP tags and add isPrecategorical field#31

Merged
raf555 merged 3 commits into
mainfrom
add-raw-response
May 5, 2026
Merged

feat(dictionary): add raw option for entry APIs for raw HTTP tags and add isPrecategorical field#31
raf555 merged 3 commits into
mainfrom
add-raw-response

Conversation

@raf555

@raf555 raf555 commented Apr 18, 2026

Copy link
Copy Markdown
Owner
  1. add isPrecategorical field to entry struct.

isPrecategorical indicates that an entry is a "prakategorial" as per KBBI dictionary. Which means it does not have definition on its own and only has meaning if given suffixes.

sample

image

in official app

image
  1. add raw option in entry APIs

by default, the API will return rendered HTML tags such as 𝗯𝗼𝗹𝗱 or 𝘪𝘵𝘢𝘭𝘪𝘤. If the raw option is enabled, it will return <b>bold</b> or <i>italic</i> instead. Useful for rendering in frontend application that uses HTML.

Some samples

Before

image

After

image

Before

image

After

image

Before

image

After

image

Before

image

After

p.s. this one is unclosed from the KBBI app (faulty HTML tag). But modern browser should be able to resolve this automatically.

image

Before

image

After

image

Before

image

After

image

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for exposing KBBI “prakategorial” entries and optionally returning raw HTML tags (instead of rendered Unicode formatting) from the entry APIs.

Changes:

  • Add isPrecategorical to entry models and Swagger schema.
  • Introduce a raw query option on entry APIs and propagate it through redirect endpoints.
  • Add internal dictionary lemma models + conversion to public pkg/kbbi models with raw/unraw selection.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/kbbi/lemma.go Adds IsPrecategorical to the public kbbi.Entry response model.
internal/dictionary/models.go Adds raw query binding to request DTOs and introduces request types for redirect endpoints.
internal/dictionary/lemma.go New internal lemma/entry types with raw/unraw conversion to pkg/kbbi responses.
internal/dictionary/iface.go Updates repository interface to return internal dictionary.Lemma instead of kbbi.Lemma.
internal/dictionary/http_handler.go Wires raw through handlers and redirect endpoints; converts internal lemma to public response based on raw.
internal/dictionary/dictionary.go Switches dictionary storage/returns to internal lemma types loaded from the asset DB.
internal/http/httphandler/handler.go Extends redirect results to support query parameters and appends them to redirect URL.
internal/swagger/swagger.yaml Updates OpenAPI spec for isPrecategorical and raw query parameters.
internal/swagger/swagger.json Same as above in JSON form.
internal/swagger/docs.go Updates embedded Swagger docs template accordingly.
assets/dict.db Updates dictionary asset to include the new fields/data needed for raw + isPrecategorical.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/dictionary/models.go
Comment thread internal/dictionary/models.go
Comment thread internal/dictionary/http_handler.go
Comment thread internal/dictionary/lemma.go
@raf555 raf555 changed the title feat(dictionary): add raw option for entry APIs to unrender HTTP tags and add isPrecategorical field feat(dictionary): add raw option for entry APIs for raw HTTP tags and add isPrecategorical field Apr 18, 2026
@raf555 raf555 requested a review from Copilot April 18, 2026 15:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 135 to 138
if entryNo > 0 {
if entryNo > len(lemmaData.Entries) {
return kbbi.Lemma{}, ErrEntryNotFound
return Lemma{}, ErrEntryNotFound
}

Copilot AI Apr 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entryNo > len(lemmaData.Entries) check can incorrectly reject valid entry numbers when the numbering in data is non-contiguous (e.g., only (3) exists but there are 2 entries). Since you already have index.entryNoMap, rely on the map lookup (or compute allowed entry numbers) instead of comparing against slice length.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix in separate PR

Comment thread internal/dictionary/lemma.go
Comment thread internal/swagger/swagger.yaml
Comment thread internal/swagger/swagger.yaml
Comment thread internal/swagger/swagger.yaml
@raf555 raf555 self-assigned this Apr 18, 2026
@raf555 raf555 merged commit 7a9c950 into main May 5, 2026
8 checks passed
@raf555 raf555 deleted the add-raw-response branch May 5, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants