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
Support request media type configuration for an API service. #102
Support request media type configuration for an API service. #102
Conversation
:label => "#{print_labels(parent_labels)}#{label}", | ||
:label_text => "#{print_labels(parent_labels)}#{label}", | ||
:accessor => "#{accessors.compact.join('.')}", | ||
:label => "#{print_labels(accessors)}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary spacing detected.
|
}, | ||
handleSubmit: function() { | ||
// FIXME | ||
Lurker.onSubmit(jQuery('#payload')); | ||
Lurker.disableSubmitButton(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason, (besides convenience aka no need to precompile lurker.js for developing that) for extracting Lurker.onSubmit
& Lurker.onComplete
when we can pass requestMediaType (or state) as parameter?
Let me clarify the things: I'd like to keep this js embedded into erb as small as possible and would be glad to move code backwards, from here to js as much as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to pass action
, payload
, requestMediaType
and method
. And it looks a little bit dirty to me. I don't like passing state
either, since it's an internal implementation detail of the React component. Finally, since request and handler callback are only used from that React component it seemed logical to me to move the code to the component itself.
If you think that it's better to move this code out of the component, I can certainly do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the code certainly belongs to the component, but nowadays Lurker
component in js it all about this form, as well.
I think we cannot eliminate passing variables from ruby to js and these 2 parts will continue to live side-by-side.
we probably can inline all the detectContentType
, fillInInfoTab
into here, but I really dislike the idea about such amount of js embedded in erb. as such I suggest:
- extract https://github.com/nebolsin/lurker/blob/feature/json-request-format/lib/lurker/templates/javascripts/lurker.js#L3L43 to say
lurker-form.js
and include it into sprockets manifest - put onSubmit & onComplete back there
- pass a part of state there (could we group these params together in order to pass say,
state.formData
?)
44ebf73
to
a45bd24
Compare
return results.join(' '); | ||
}, | ||
|
||
performRequest: function(host, method, template, values, payload, contentType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long.
a45bd24
to
5240801
Compare
switch (Lurker.detectContentType(xhr)) { | ||
case "json": | ||
var json = JSON.stringify(JSON.parse(xhr.responseText), null, 2); | ||
var content = hljs.highlightAuto(json).value; | ||
content = hljs.highlightAuto(json).value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'hljs' is not defined.
1ac5419
to
fb1ab0a
Compare
fb1ab0a
to
b19d89c
Compare
Support request media type configuration for an API service.
Service can specify several media types which it can consume as an input.
Generated browsable HTML documentation allows user to select from the consumable media types and generate requests and cURL templates appropriately.
If no
consumes
key is present in the service config, then it's assumed to beapplication/x-www-form-urlencoded
.