71 lines
2.1 KiB
JavaScript
71 lines
2.1 KiB
JavaScript
const mapper = require('../src/java-model')
|
|
|
|
const service = {
|
|
namespace: "de.nclazz.test.v0",
|
|
models: [
|
|
{
|
|
"name": "user",
|
|
"plural": "users",
|
|
"fields": [
|
|
{
|
|
"name": "id",
|
|
"type": "string",
|
|
"required": true,
|
|
"attributes": [],
|
|
"annotations": [],
|
|
"description": "ID of the user as a 32 char long hex string.",
|
|
"minimum": 32,
|
|
"maximum": 32
|
|
},
|
|
{
|
|
"name": "name",
|
|
"type": "string",
|
|
"required": true,
|
|
"attributes": [],
|
|
"annotations": [],
|
|
"description": "Name of the user, which can be the email address.",
|
|
"minimum": 8,
|
|
"maximum": 32
|
|
},
|
|
{
|
|
"name": "email",
|
|
"type": "string",
|
|
"required": true,
|
|
"attributes": [],
|
|
"annotations": [
|
|
"personal_data"
|
|
],
|
|
"description": "Email of the user.",
|
|
"minimum": 4,
|
|
"maximum": 64
|
|
},
|
|
{
|
|
"name": "status",
|
|
"type": "userStatus",
|
|
"required": true,
|
|
"attributes": [],
|
|
"annotations": [],
|
|
"description": "Status of the user as described in the user_status enum."
|
|
},
|
|
{
|
|
"name": "roles",
|
|
"type": "[role]",
|
|
"required": true,
|
|
"attributes": [],
|
|
"annotations": [],
|
|
"description": "Roles assigned to the user."
|
|
}
|
|
],
|
|
"attributes": [],
|
|
"interfaces": [],
|
|
"description": "A user defined by an id and an username."
|
|
}
|
|
]
|
|
}
|
|
|
|
const mapped = mapper.mapJavaModels(service.models, service.namespace)
|
|
|
|
console.log(mapped)
|
|
console.log(mapped[0].fields)
|
|
console.log(mapped[0].fields[0])
|
|
console.log(mapped[0].fields[3]) |