AnWeber / vscode-httpyac

Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=anweber.vscode-httpyac
MIT License
222 stars 20 forks source link

httpyac.responseViewLanguageMap not works #193

Closed IRuzhnikov closed 1 year ago

IRuzhnikov commented 1 year ago

Hi! i was try use it like (for pretty print in preview)

"httpyac.responseViewLanguageMap": {
    "application/json-rpc": "json"
},

and when I opened sourcecode i fount strange strings

function getExtensionByMimeTypes(response: httpyac.HttpResponse) {
  if (response?.contentType?.contentType) {
    return extension(response?.contentType?.contentType);
  }
  return false;
}

but in a same time another functions used just one chain call to contentType

function getExtensionByRegexMimetype(response: httpyac.HttpResponse): string | false {
  if (response?.contentType) {
    const contentType = response?.contentType;
    if (httpyac.utils.isMimeTypeJSON(contentType)) {
      return 'json';
    }
   //....
}

Permalink to original code: https://github.com/AnWeber/vscode-httpyac/blob/c8c37e4658715282cf2bf286829ed981f736e81c/src/view/responseItem.ts#L141

Thanks!

AnWeber commented 1 year ago

To use the preview mode in VSCode, the response must be saved as a file. The display language is determined by the file extension. Because of this I had the problem that I do not know the file extension for a LanguageId. My way is to save the most common LanguageId with the correct file extension, but if necessary to set the LanguageId active when opening the response, if it is available in the map.