-
-
Notifications
You must be signed in to change notification settings - Fork 147
JSON formatting for application/vnd.api+json does not work #382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
rest.nvim can’t understand non-standard mimetypes like |
Is this still supposed to work? I get this error on startup:
I've tried a bunch of variants like changing I'm on commit 97cc922. |
@mawkler setup above is using legacy config. So yes, there's no btw for vim.api.nvim_create_autocmd("FileType", {
pattern = "vnd.api+json",
callback = function (ev)
vim.bo[ev.buf].filetype = "json"
end
}) |
Thank you for the response! However, I get the following error message:
Here's the request file that I'm using: GET https://httpbin.org/response-headers?content-type=application/vnd.api%2Bjson It seems to be the Here's the minimal config that I'm using: Click to expandlocal lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
vim.keymap.set('n', '<c-q>', vim.cmd.quitall)
vim.api.nvim_create_autocmd('FileType', {
pattern = 'vnd.api+json',
group = augroup,
callback = function(ev)
vim.bo[ev.buf].filetype = 'json'
end
})
require('lazy').setup({
{
"rest-nvim/rest.nvim",
dependencies = 'nvim-treesitter/nvim-treesitter',
},
}) |
This has been fixed now. example config: vim.g.rest_nvim = {
request = {
hooks = {
encode_url = false,
},
},
} |
@boltlessengineer Thank you for fixing this! I no longer get the error message. Is it possible to also set the filetype of the response body to JSON in the case of |
Current version will set filetype to json for |
@boltlessengineer Hmm you're right, I tested against httpbin like so, and it does work:
However, it does not work for responses from the real server that I'm sending requests to at work. I tried imitating the full response via The only difference that I can see while comparing the responses is that the real server does not set a |
@mawkler I don't think the absence of HTTP/1.1 200 OK
Content-Type: application/json
{"message":"Test response"} It's quite hard to help you without actually testing with the response you are dealing with. It would be helpful if you share the actual response but I understand if you can't because of security reasons. If you don't mind sharing the response from the server you are working with, please share the output of following command: curl -sL -v https://example.com -X GET -H "User-Agent: rest.nvim v3.9.1" replace Alternatively, can you share your log output when running the request? vim.g.rest_nvim = {
_log_level = vim.log.levels.DEBUG,
} |
Here's the output of Click to expand
And here are my logs: Click to expand
I noticed that it says |
Yes! Thank you for providing those. So
Doesn't your response body start with I think setting json formatter will fix this issue because it will format json body to start with correct pattern. |
That solved the issue for me, thank you! After setting |
If I include the following in my
.http
file, I get formatted results:This suggests to me that I have everything installed correctly, including jq for formatting. But if I include the following config (based on #143 (comment)):
And query a JSON:API (from a Drupal site), then I get the following warning before the results come back unformatted:
Any idea what I'm doing wrong?
The text was updated successfully, but these errors were encountered: