feat(dictionary): add raw option for entry APIs for raw HTTP tags and add isPrecategorical field#31
Conversation
There was a problem hiding this comment.
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
isPrecategoricalto entry models and Swagger schema. - Introduce a
rawquery option on entry APIs and propagate it through redirect endpoints. - Add internal dictionary lemma models + conversion to public
pkg/kbbimodels 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.
There was a problem hiding this comment.
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.
| if entryNo > 0 { | ||
| if entryNo > len(lemmaData.Entries) { | ||
| return kbbi.Lemma{}, ErrEntryNotFound | ||
| return Lemma{}, ErrEntryNotFound | ||
| } |
There was a problem hiding this comment.
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.
isPrecategoricalfield 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
in official app
rawoption in entry APIsby 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
After
Before
After
Before
After
Before
After
p.s. this one is unclosed from the KBBI app (faulty HTML tag). But modern browser should be able to resolve this automatically.
Before
After
Before
After