-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from diplodoc-platform/features_pack
- Loading branch information
Showing
8 changed files
with
389 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`openapi project with examples renders example field 1`] = ` | ||
"<div class="openapi"> | ||
# example.array | ||
## Request | ||
<div class="openapi__request__wrapper"> | ||
<div class="openapi__request" style="--method: var(--dc-openapi-methods-post)"> | ||
POST {.openapi__method} | ||
\`\`\` | ||
http://localhost:8080/test | ||
\`\`\` | ||
</div> | ||
</div> | ||
Generated server url{.openapi__request__description} | ||
#### Body | ||
{% cut "application/json" %} | ||
\`\`\`json | ||
[ | ||
{ | ||
"test": 1 | ||
}, | ||
{ | ||
"test": 2 | ||
} | ||
] | ||
\`\`\` | ||
{% endcut %} | ||
any[] | ||
## Responses | ||
<div class="openapi__response__code__200"> | ||
## 200 OK | ||
Base 200 response | ||
#### Body | ||
{% cut "application/json" %} | ||
\`\`\`json | ||
{} | ||
\`\`\` | ||
{% endcut %} | ||
</div> | ||
<!-- markdownlint-disable-file --> | ||
</div>" | ||
`; | ||
|
||
exports[`openapi project with examples renders infered example 1`] = ` | ||
"<div class="openapi"> | ||
# example.array | ||
## Request | ||
<div class="openapi__request__wrapper"> | ||
<div class="openapi__request" style="--method: var(--dc-openapi-methods-post)"> | ||
POST {.openapi__method} | ||
\`\`\` | ||
http://localhost:8080/test | ||
\`\`\` | ||
</div> | ||
</div> | ||
Generated server url{.openapi__request__description} | ||
#### Body | ||
{% cut "application/json" %} | ||
\`\`\`json | ||
[ | ||
{ | ||
"name": "string" | ||
} | ||
] | ||
\`\`\` | ||
{% endcut %} | ||
[Cat](#cat)[] | ||
### Cat | ||
#||| **Name** | **Type** | **Description** || | ||
|| name | string | |||# | ||
## Responses | ||
<div class="openapi__response__code__200"> | ||
## 200 OK | ||
Base 200 response | ||
#### Body | ||
{% cut "application/json" %} | ||
\`\`\`json | ||
{} | ||
\`\`\` | ||
{% endcut %} | ||
</div> | ||
<!-- markdownlint-disable-file --> | ||
</div>" | ||
`; | ||
|
||
exports[`openapi project with examples renders nested arrays exmaple 1`] = ` | ||
"<div class="openapi"> | ||
# example.array | ||
## Request | ||
<div class="openapi__request__wrapper"> | ||
<div class="openapi__request" style="--method: var(--dc-openapi-methods-post)"> | ||
POST {.openapi__method} | ||
\`\`\` | ||
http://localhost:8080/test | ||
\`\`\` | ||
</div> | ||
</div> | ||
Generated server url{.openapi__request__description} | ||
#### Body | ||
{% cut "application/json" %} | ||
\`\`\`json | ||
[ | ||
[ | ||
{ | ||
"name": "string" | ||
} | ||
] | ||
] | ||
\`\`\` | ||
{% endcut %} | ||
[Cat](#cat)[][] | ||
### Cat | ||
#||| **Name** | **Type** | **Description** || | ||
|| name | string | |||# | ||
## Responses | ||
<div class="openapi__response__code__200"> | ||
## 200 OK | ||
Base 200 response | ||
#### Body | ||
{% cut "application/json" %} | ||
\`\`\`json | ||
{} | ||
\`\`\` | ||
{% endcut %} | ||
</div> | ||
<!-- markdownlint-disable-file --> | ||
</div>" | ||
`; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import {DocumentBuilder, run} from '../__helpers__/run'; | ||
|
||
const name = 'example.array'; | ||
describe('openapi project with examples', () => { | ||
it('renders example field', async () => { | ||
const spec = new DocumentBuilder(name) | ||
.request({ | ||
schema: { | ||
example: [ | ||
{ | ||
test: 1, | ||
}, | ||
{ | ||
test: 2, | ||
}, | ||
], | ||
type: 'array', | ||
items: {}, | ||
}, | ||
}) | ||
.response(200, { | ||
description: 'Base 200 response', | ||
schema: { | ||
type: 'object', | ||
}, | ||
}) | ||
.build(); | ||
|
||
const fs = await run(spec); | ||
|
||
const page = fs.match(name); | ||
|
||
expect(page).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders infered example', async () => { | ||
const spec = new DocumentBuilder(name) | ||
.request({ | ||
schema: { | ||
type: 'array', | ||
items: DocumentBuilder.ref('Cat'), | ||
}, | ||
}) | ||
.response(200, { | ||
description: 'Base 200 response', | ||
schema: { | ||
type: 'object', | ||
}, | ||
}) | ||
.component('Cat', { | ||
type: 'object', | ||
properties: { | ||
name: { | ||
type: 'string', | ||
}, | ||
}, | ||
}) | ||
.build(); | ||
|
||
const fs = await run(spec); | ||
|
||
const page = fs.match(name); | ||
|
||
expect(page).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders nested arrays exmaple', async () => { | ||
const spec = new DocumentBuilder(name) | ||
.request({ | ||
schema: { | ||
type: 'array', | ||
items: { | ||
type: 'array', | ||
items: DocumentBuilder.ref('Cat'), | ||
}, | ||
}, | ||
}) | ||
.response(200, { | ||
description: 'Base 200 response', | ||
schema: { | ||
type: 'object', | ||
}, | ||
}) | ||
.component('Cat', { | ||
type: 'object', | ||
properties: { | ||
name: { | ||
type: 'string', | ||
}, | ||
}, | ||
}) | ||
.build(); | ||
|
||
const fs = await run(spec); | ||
|
||
const page = fs.match(name); | ||
|
||
expect(page).toMatchSnapshot(); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
src/__tests__/example.test.ts → src/__tests__/examples/base.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.