-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(W-17309546): add RAML definition and example data for user API
- Loading branch information
Showing
6 changed files
with
145 additions
and
25 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,24 @@ | ||
#%RAML 1.0 | ||
title: test_for_support | ||
mediaType: application/json | ||
|
||
|
||
|
||
types: | ||
User: | ||
type: object | ||
properties: | ||
id: integer | ||
name: string | ||
email: string | ||
postal_code: string | ||
companyDateEntry: date-only | ||
|
||
/test: | ||
get: | ||
description: Obtenir la liste des utilisateurs | ||
responses: | ||
200: | ||
body: | ||
type: User[] | ||
example: !include /examples/employees/user-examples.raml |
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,17 @@ | ||
#%RAML 1.0 NamedExample | ||
value: | ||
- id: 1 | ||
name: Alice Dupont | ||
email: [email protected] | ||
companyDateEntry: 2003-05-14 | ||
postal_code: "075001" | ||
- id: 2 | ||
name: Bob Martin | ||
email: [email protected] | ||
companyDateEntry: 2004-05-04 | ||
postal_code: "169002" | ||
- id: 3 | ||
name: Charlie Durand | ||
email: [email protected] | ||
companyDateEntry: 2003-08-11 | ||
postal_code: "013003" |
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
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,60 @@ | ||
import { fixture, assert, html } from '@open-wc/testing'; | ||
import { AmfLoader } from './amf-loader.js'; | ||
import '../api-example-generator.js'; | ||
|
||
describe('W-17309546', () => { | ||
async function basicFixture(amf) { | ||
return (await fixture(html`<api-example-generator | ||
.amf="${amf}"></api-example-generator>`)); | ||
} | ||
|
||
const apiFile = 'W-17309546'; | ||
|
||
[ | ||
['json+ld data model', false], | ||
['Compact data model', true] | ||
].forEach(([label, compact]) => { | ||
describe(label, () => { | ||
let element; | ||
let amf; | ||
|
||
before(async () => { | ||
amf = await AmfLoader.load(compact, apiFile); | ||
}); | ||
|
||
beforeEach(async () => { | ||
element = await basicFixture(amf); | ||
}); | ||
|
||
it('renders examples right', () => { | ||
const payloads = AmfLoader.lookupReturnsPayload(amf, '/test', 'get', 200); | ||
const result = element.generatePayloadsExamples(payloads, 'application/json'); | ||
assert.typeOf(result, 'array'); | ||
const item = result[0]; | ||
assert.equal(item.value, `[ | ||
{ | ||
"id": 1, | ||
"name": "Alice Dupont", | ||
"email": "[email protected]", | ||
"companyDateEntry": "2003-05-14", | ||
"postal_code": "075001" | ||
}, | ||
{ | ||
"id": 2, | ||
"name": "Bob Martin", | ||
"email": "[email protected]", | ||
"companyDateEntry": "2004-05-04", | ||
"postal_code": "169002" | ||
}, | ||
{ | ||
"id": 3, | ||
"name": "Charlie Durand", | ||
"email": "[email protected]", | ||
"companyDateEntry": "2003-08-11", | ||
"postal_code": "013003" | ||
} | ||
]`); | ||
}); | ||
}); | ||
}); | ||
}); |