Skip to content
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

Bump up httpsnippet to 1.22.0 for Kotlin and Axios code generation support #2526

Merged
merged 4 commits into from Aug 20, 2020
Merged

Conversation

seanghay
Copy link
Contributor

Closes #2516

httpsnippet@1.22.0 comes with Kotlin and Axios code generation.

@netlify
Copy link

netlify bot commented Aug 18, 2020

Deploy preview for insomnia-storybook ready!

Built with commit cce50c8

https://deploy-preview-2526--insomnia-storybook.netlify.app

@seanghay
Copy link
Contributor Author

However, it doesn't highlight Kotlin code. :/
image

@develohpanda develohpanda added this to Needs Review ❤ in Insomnia Kanban Aug 18, 2020
@develohpanda
Copy link
Contributor

Looks like defining mime type as text/x-kotlin should get it working? https://www.libraart.ro/js/CodeMirror/mode/kotlin/index.html

@seanghay
Copy link
Contributor Author

Looks like defining mime type as text/x-kotlin should get it working? libraart.ro/js/CodeMirror/mode/kotlin/index.html

I really don't know where to add that mine-type to.

@develohpanda
Copy link
Contributor

I really don't know where to add that mine-type to.

No worries - I'm not familiar with this area of code off the top of my head, so when I get a chance to dig into this further I'll chime back 😊

@develohpanda
Copy link
Contributor

develohpanda commented Aug 20, 2020

@seanghay Looks like you just need to add another condition to (the end of) this function.

static _normalizeMode(mode) {
const mimeType = mode ? mode.split(';')[0] : 'text/plain';
if (mimeType.includes('graphql-variables')) {
return 'graphql-variables';
} else if (mimeType.includes('graphql')) {
// Because graphQL plugin doesn't recognize application/graphql content-type
return 'graphql';
} else if (CodeEditor._isJSON(mimeType)) {
return 'application/json';
} else if (CodeEditor._isEDN(mimeType)) {
return 'application/edn';
} else if (CodeEditor._isXML(mimeType)) {
return 'application/xml';
} else {
return mimeType;
}
}

...
+   } else if (mimeType.includes('kotlin')) {
+     return 'text/x-kotlin';
+   } else { 
      return mimeType; 
    } 
...

For context: all of the code blocks in Insomnia use CodeMirror as the underlying component, as does the generate code modal: generate-code-modal.js > code-editor.js > CodeMirror.

@seanghay
Copy link
Contributor Author

It's working now! Thanks @develohpanda

Copy link
Contributor

@develohpanda develohpanda left a comment

Choose a reason for hiding this comment

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

Nice 🎉 Excited to get this merged!

@develohpanda develohpanda merged commit 827783e into Kong:develop Aug 20, 2020
Insomnia Kanban automation moved this from Needs Review ❤ to Done 🎉 Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Insomnia Kanban
  
Done 🎉
Development

Successfully merging this pull request may close these issues.

Kotlin Http Request Code Generation
2 participants