Skip to content

Commit 1dd06a2

Browse files
authored
Merge branch 'master' into feature/nullable
2 parents 18d126c + 8274a80 commit 1dd06a2

23 files changed

+449
-58
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,35 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1212

1313
### Removed
1414

15+
# 4.37.2 (30 August 2024)
16+
## Fixed
17+
- Stop response fields from overflowing to the dark box zone [#868](https://github.com/knuckleswtf/scribe/pull/868)
18+
- Don't ignore comments for validator parameters with non string/array (e.g. conditional) rule lists [#880](https://github.com/knuckleswtf/scribe/pull/880)
19+
- Allow custom output path for static and external_static instead of only static [#884](https://github.com/knuckleswtf/scribe/pull/884)
20+
21+
22+
# 4.37.1 (11 July 2024)
23+
## Fixed
24+
- Multipart file upload in `elements` theme [#864](https://github.com/knuckleswtf/scribe/pull/864)
25+
- Properly set multiple responses in OpenAPI spec with the same status code [#863](https://github.com/knuckleswtf/scribe/pull/863)
26+
27+
28+
29+
# 4.37.0 (17 June 2024)
30+
## Added
31+
- Support multiple responses in OpenAPI spec using oneOf [#739](https://github.com/knuckleswtf/scribe/pull/739)
32+
33+
34+
# 4.36.0 (27 May 2024)
35+
## Added
36+
- Add `afterResponseCall` hook [#847](https://github.com/knuckleswtf/scribe/pull/847)
37+
38+
## Fixed
39+
- Unescape tryItOutBaseURL [09b49b582](https://github.com/knuckleswtf/scribe/commit/09b49b5829647597825b2cc7162382e926d53f90)
40+
- Ignore `external.html_attributes` for upgrades [f56a48014](https://github.com/knuckleswtf/scribe/commit/f56a480140d25ada8a441f69db9a6a14b5f0dcd1)
41+
- Fix missing title and logo in `elements` theme [#844](https://github.com/knuckleswtf/scribe/pull/844)
42+
43+
1544
# 4.35.0 (26 March 2024)
1645
## Modified
1746
- Allow examples to be shown in response fields [#825](https://github.com/knuckleswtf/scribe/pull/825)

config/scribe.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,13 @@
241241
Strategies\Responses\UseResponseFileTag::class,
242242
[
243243
Strategies\Responses\ResponseCalls::class,
244-
['only' => ['GET *']]
244+
[
245+
'only' => ['GET *'],
246+
// Disable debug mode when generating response calls to avoid error stack traces in responses
247+
'config' => [
248+
'app.debug' => false,
249+
],
250+
]
245251
]
246252
],
247253
'responseFields' => [

resources/css/theme-default.style.css

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ html {
688688
.content>p,
689689
.content>table,
690690
.content>ul,
691+
.content>div,
691692
.content>form>aside,
692693
.content>form>details,
693694
.content>form>h1,
@@ -893,6 +894,11 @@ html {
893894
text-shadow: 0 1px 2px rgba(0, 0, 0, .4)
894895
}
895896

897+
.content blockquote pre.sf-dump,
898+
.content pre pre.sf-dump {
899+
width: 100%;
900+
}
901+
896902
.content .annotation {
897903
background-color: #292929;
898904
color: #fff;
@@ -961,20 +967,6 @@ html {
961967
.page-wrapper .lang-selector {
962968
display: none
963969
}
964-
.content aside,
965-
.content dl,
966-
.content h1,
967-
.content h2,
968-
.content h3,
969-
.content h4,
970-
.content h5,
971-
.content h6,
972-
.content ol,
973-
.content p,
974-
.content table,
975-
.content ul {
976-
margin-right: 0
977-
}
978970
.content>aside,
979971
.content>details,
980972
.content>dl,
@@ -988,6 +980,7 @@ html {
988980
.content>p,
989981
.content>table,
990982
.content>ul,
983+
.content>div,
991984
.content>form>aside,
992985
.content>form>details,
993986
.content>form>h1,

resources/js/tryitout.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,30 @@ function handleResponse(endpointId, response, status, headers) {
139139

140140
const responseContentEl = document.querySelector('#execution-response-content-' + endpointId);
141141

142+
// Check if the response contains Laravel's dd() default dump output
143+
const isLaravelDump = response.includes('Sfdump');
144+
145+
// If it's a Laravel dd() dump, use innerHTML to render it safely
146+
if (isLaravelDump) {
147+
responseContentEl.innerHTML = response === '' ? responseContentEl.dataset.emptyResponseText : response;
148+
} else {
149+
// Otherwise, stick to textContent for regular responses
150+
responseContentEl.textContent = response === '' ? responseContentEl.dataset.emptyResponseText : response;
151+
}
152+
142153
// Prettify it if it's JSON
143154
let isJson = false;
144155
try {
145156
const jsonParsed = JSON.parse(response);
146157
if (jsonParsed !== null) {
147158
isJson = true;
148159
response = JSON.stringify(jsonParsed, null, 4);
160+
responseContentEl.textContent = response;
149161
}
150162
} catch (e) {
151163

152164
}
153-
responseContentEl.textContent = response === '' ? responseContentEl.dataset.emptyResponseText : response;
165+
154166
isJson && window.hljs.highlightElement(responseContentEl);
155167
const statusEl = document.querySelector('#execution-response-status-' + endpointId);
156168
statusEl.textContent = ` (${status})`;

resources/views/external/elements.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<head>
55
<meta charset="utf-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7-
<title>Elements in HTML</title>
7+
<title>{!! $metadata['title'] !!}</title>
88
<!-- Embed elements Elements via Web Component -->
99
<script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
1010
<link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">
@@ -25,7 +25,9 @@
2525
router="hash"
2626
layout="sidebar"
2727
hideTryIt="{!! ($tryItOut['enabled'] ?? true) ? '' : 'true'!!}"
28+
@if(!empty($metadata['logo']))
2829
logo="{!! $metadata['logo'] !!}"
30+
@endif
2931
/>
3032

3133
</body>

resources/views/themes/elements/components/field-details.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ class="svg-inline--fa fa-chevron-right fa-fw fa-sm sl-icon" role="img"
4949
@endif
5050
</div>
5151
@endif
52-
@if(!$hasChildren && !is_null($example) && $example != '')
52+
@if(!$hasChildren && !is_null($example) && $example !== '')
5353
<div class="sl-stack sl-stack--horizontal sl-stack--2 sl-flex sl-flex-row sl-items-baseline sl-text-muted">
5454
<span>Example:</span> <!-- <span> important for spacing -->
5555
<div class="sl-flex sl-flex-1 sl-flex-wrap" style="gap: 4px;">
5656
<div class="sl-max-w-full sl-break-all sl-px-1 sl-bg-canvas-tint sl-text-muted sl-rounded sl-border">
57-
{{ is_array($example) ? json_encode($example) : $example }}
57+
{{ is_array($example) || is_bool($example) ? json_encode($example) : $example }}
5858
</div>
5959
</div>
6060
</div>

resources/views/themes/elements/index.blade.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ function tryItOut(btnElement) {
111111
});
112112
}
113113
114+
// content type has to be unset otherwise file upload won't work
115+
if (form.dataset.hasfiles === "1") {
116+
delete headers['Content-Type'];
117+
}
118+
114119
return preflightPromise.then(() => makeAPICall(method, path, body, query, headers, endpointId))
115120
.then(([responseStatus, statusText, responseContent, responseHeaders]) => {
116121
responsePanel.hidden = false;
@@ -132,6 +137,9 @@ function tryItOut(btnElement) {
132137
}
133138
} catch (e) {}
134139
140+
// Replace HTML entities
141+
responseContent = responseContent.replace(/[<>&]/g, (i) => '&#' + i.charCodeAt(0) + ';');
142+
135143
contentEl.innerHTML = responseContent;
136144
isJson && window.hljs.highlightElement(contentEl);
137145
})

src/Commands/GenerateDocumentation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ protected function upgradeConfigFileIfNeeded(): void
178178
)
179179
->dontTouch(
180180
'routes', 'example_languages', 'database_connections_to_transact', 'strategies', 'laravel.middleware',
181-
'postman.overrides', 'openapi.overrides', 'groups', 'examples.models_source'
181+
'postman.overrides', 'openapi.overrides', 'groups', 'examples.models_source', 'external.html_attributes'
182182
);
183183
$changes = $upgrader->dryRun();
184184
if (!empty($changes)) {

src/Commands/Upgrade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function handle(): void
4343

4444
$upgrader = Upgrader::ofConfigFile("config/$this->configName.php", __DIR__ . '/../../config/scribe.php')
4545
->dontTouch('routes', 'laravel.middleware', 'postman.overrides', 'openapi.overrides',
46-
'example_languages', 'database_connections_to_transact', 'strategies', 'examples.models_source')
46+
'example_languages', 'database_connections_to_transact', 'strategies', 'examples.models_source', 'external.html_attributes')
4747
->move('default_group', 'groups.default')
4848
->move('faker_seed', 'examples.faker_seed');
4949

src/Extracting/DatabaseTransactionHelpers.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ private function connectionsToTransact()
1515

1616
private function startDbTransaction()
1717
{
18-
$database = app('db');
19-
2018
foreach ($this->connectionsToTransact() as $connection) {
19+
$database ??= app('db');
20+
2121
$driver = $database->connection($connection);
2222

2323
if (self::driverSupportsTransactions($driver)) {
@@ -30,7 +30,6 @@ private function startDbTransaction()
3030
" If you aren't using this database, remove it from the `database_connections_to_transact` config array."
3131
);
3232
}
33-
continue;
3433
} else {
3534
$driverClassName = get_class($driver);
3635
throw DatabaseTransactionsNotSupported::create($connection, $driverClassName);
@@ -43,9 +42,9 @@ private function startDbTransaction()
4342
*/
4443
private function endDbTransaction()
4544
{
46-
$database = app('db');
47-
4845
foreach ($this->connectionsToTransact() as $connection) {
46+
$database ??= app('db');
47+
4948
$driver = $database->connection($connection);
5049
try {
5150
$driver->rollback();

0 commit comments

Comments
 (0)