mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
- added javascript for collapsing sections in json-response, - fixed usage of private service-alias (that will be removed by RemovePrivateAliases-compiler pass)
This commit is contained in:
parent
6a9ca36bb4
commit
d73531aeb5
@ -616,3 +616,8 @@ form .request-content {
|
||||
.motd {
|
||||
padding:20px;
|
||||
}
|
||||
|
||||
.json-toggle-section {
|
||||
color: #660;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
@ -243,7 +243,7 @@
|
||||
$btn = $container.parents('.pane').find('.to-prettify');
|
||||
|
||||
$container.removeClass('prettyprinted');
|
||||
$container.html(prettifyResponse(rawData));
|
||||
$container.html(attachCollapseMarker(prettifyResponse(rawData)));
|
||||
prettyPrint && prettyPrint();
|
||||
|
||||
$btn.removeClass('to-prettify');
|
||||
@ -275,7 +275,7 @@
|
||||
}
|
||||
}
|
||||
return body;
|
||||
}
|
||||
};
|
||||
|
||||
$('#save_api_auth').click(function(event) {
|
||||
$.each(apiAuthKeys, function(_, value) {
|
||||
@ -306,6 +306,22 @@
|
||||
$(this).addClass('selected');
|
||||
});
|
||||
|
||||
var getJsonCollapseHtml = function(sectionOpenCharacter) {
|
||||
var $toggler = $('<span>').addClass('json-collapse-section').
|
||||
attr('data-section-open-character', sectionOpenCharacter).
|
||||
append($('<span>').addClass('json-collapse-marker')
|
||||
.html('▿')
|
||||
).append(sectionOpenCharacter);
|
||||
return $('<div>').append($toggler).html();
|
||||
};
|
||||
|
||||
var attachCollapseMarker = function (prettifiedJsonString) {
|
||||
prettifiedJsonString = prettifiedJsonString.replace(/(\{|\[)\n/g, function(match, sectionOpenCharacter) {
|
||||
return getJsonCollapseHtml(sectionOpenCharacter) + '<span class="json-collapse-content">\n';
|
||||
});
|
||||
return prettifiedJsonString.replace(/([^\[][\}\]]),?\n/g, '$1</span>\n');
|
||||
};
|
||||
|
||||
var prettifyResponse = function(text) {
|
||||
try {
|
||||
var data = typeof text === 'string' ? JSON.parse(text) : text;
|
||||
@ -570,6 +586,25 @@
|
||||
}
|
||||
});
|
||||
|
||||
$('.json-collapse-section').on('click', function(){
|
||||
var openChar = $(this).data('section-open-character'),
|
||||
closingChar = (openChar == '{' ? '}' : ']');
|
||||
if ($(this).next('.json-collapse-content').is(':visible')) {
|
||||
$(this).html('⊕' + openChar + '...' + closingChar);
|
||||
} else {
|
||||
$(this).html('▿' + $(this).data('section-open-character'));
|
||||
}
|
||||
$(this).next('.json-collapse-content').toggle();
|
||||
});
|
||||
|
||||
$(document).on('copy', '.prettyprinted', function () {
|
||||
var $toggleMarkers = $(this).find('.json-collapse-marker');
|
||||
$toggleMarkers.hide();
|
||||
setTimeout(function () {
|
||||
$toggleMarkers.show();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
$('.pane.sandbox').on('click', '.to-raw', function(e) {
|
||||
renderRawBody($(this).parents('.pane').find('.response'));
|
||||
|
||||
|
@ -14,7 +14,12 @@ class ValidationParserTest extends WebTestCase
|
||||
public function setUp()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$factory = $container->get('validator')->getMetadataFactory();
|
||||
|
||||
if($container->has('validator.mapping.class_metadata_factory')){
|
||||
$factory = $container->get('validator.mapping.class_metadata_factory');
|
||||
}else {
|
||||
$factory = $container->get('validator');
|
||||
}
|
||||
|
||||
if (version_compare(Kernel::VERSION, '2.2.0', '<')) {
|
||||
$this->parser = new ValidationParserLegacy($factory);
|
||||
|
Loading…
x
Reference in New Issue
Block a user