docbrown/app/views/api/v1/articles/search.json.jbuilder
Ridhwana e67454fa53
Preparation of endpoint and files required for ChatGPT Plugin (#19394)
* feat: add the ./wellknown/ai-plugin.json file

* feat: add a logo

* feat: firts attempt at open_api file with endpoint we thought we'd use

* feat: add a search action to teh articles controller that build up teh appropriate json

* feat: add a query param to the article index

* feat: add some chatgpt endpoints and file paths to CORS

* feat: update the openapi yml file to reflect the article search endpoint

* fix: use the correct concept

* feat: replace the logo

* feat: update the ai-json file

* feat: update the openapi file

* feat: update the api and it's params

* feat: update the search query

* fix: ordering

* feat: cors debug

* fix: logic with markdown

* chore: fix test

* spec: article

* spec: article

* spec: article

* Update public/.well-known/ai-plugin.json

* Update public/openapi.yml

---------

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
2023-04-27 16:51:24 -04:00

23 lines
832 B
Ruby

json.array! @articles do |article|
json.partial! "api/v1/articles/article", article: article
json.body_markdown article.body_markdown if article.respond_to?(:body_markdown)
# /api/articles and /api/articles/:id have opposite representations
# of `tag_list` and `tags and we can't align them without breaking the API,
# this is fully documented in the API docs
# see <https://github.com/forem/forem/issues/4206> for more details
json.tag_list article.cached_tag_list_array
json.tags article.cached_tag_list
json.partial! "api/v1/shared/user", user: article.user
if article.organization
json.partial! "api/v1/shared/organization", organization: article.organization
end
flare_tag = FlareTag.new(article).tag
if flare_tag
json.partial! "api/v1/articles/flare_tag", flare_tag: flare_tag
end
end