Commit 6b78c0de authored by Mahdi Sellami's avatar Mahdi Sellami

generated server from specification

parent dfd3848a
Pipeline #24147 failed with stages
in 2 minutes and 13 seconds
......@@ -18,3 +18,24 @@ Through a RESTful API as interface, a public service provider module can be easi
![Alt text](figures/sequence_c4ai.png?raw=true "Title")
## 3. How to use
### Overview
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub.
#### Running the server
To run the server, run:
```
npm start
```
To view the Swagger UI interface:
```
open http://localhost:8080/docs
```
This project leverages the mega-awesome [swagger-tools](https://github.com/apigee-127/swagger-tools) middleware which does most all the work.
openapi: 3.0.3
info:
title: OpenAPIs für E-Government
description: This is a sample specification of the interfaces based on a project
in the city of Munich for the public sector.
version: 0.0.3
servers:
- url: /
tags:
- name: info
description: Information about government administration services
- name: application
description: Application for an administration case
- name: status
description: Status information and documents of an administration case
- name: decision
description: Decision of an administration case
- name: verification
description: Verification of a decision of an administration case
paths:
/leistungen:
get:
tags:
- info
summary: Find information about the offered services
operationId: getAllServices
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/inline_response_200'
x-swagger-router-controller: Info
/leistungen/{leikaId}:
get:
tags:
- info
summary: Find information about a specific service by its LeiKa ID
operationId: getServiceByLeiKaId
parameters:
- name: leikaId
in: path
description: Leika ID
required: true
style: simple
explode: false
schema:
type: string
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Service'
x-swagger-router-controller: Info
/verfahren:
post:
tags:
- application
summary: Submit a new application including the application documents for an
administration case
operationId: postCaseApplication
requestBody:
description: Application details
content:
application/json:
schema:
$ref: '#/components/schemas/Verfahren'
required: true
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Verfahren'
x-swagger-router-controller: Application
/verfahren/{verfahrensId}:
get:
tags:
- status
summary: Request the current status of an administration case by its case ID
operationId: getCaseByVerfahrensId
parameters:
- name: verfahrensId
in: path
required: true
style: simple
explode: false
schema:
type: string
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Verfahren'
x-swagger-router-controller: Status
/verfahren/{verfahrensId}/dataobjects/entscheidung:
get:
tags:
- decision
summary: Request the decision document of an administration case by its case
ID
operationId: getCaseDecisionDocumentByVerfahrensId
parameters:
- name: verfahrensId
in: path
required: true
style: simple
explode: false
schema:
type: string
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/DataObject'
x-swagger-router-controller: Decision
/sachverhalte:
post:
tags:
- verification
summary: Submit a new verification request, e.g. to verify a decision document
or a person
operationId: postVerifcationRequest
requestBody:
description: Decision details
content:
application/json:
schema:
$ref: '#/components/schemas/body'
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Verification'
x-swagger-router-controller: Verification
/sachverhalte/{sachverhaltId}:
get:
tags:
- verification
summary: Request the status and outcome of a verification request by its verification
ID
operationId: getVerificationByVerificationId
parameters:
- name: sachverhaltId
in: path
required: true
style: simple
explode: false
schema:
type: string
responses:
"200":
description: Successful operation
content:
application/Json:
schema:
$ref: '#/components/schemas/Verification'
x-swagger-router-controller: Verification
components:
schemas:
Service:
type: object
properties:
leikaId:
type: string
serviceDescription:
type: string
shortText:
type: string
fullText:
type: string
responsibleAuthority:
type: string
fimMasterData:
type: object
description: FIM master data of this service
example:
leikaId: leikaId
fimMasterData: {}
shortText: shortText
fullText: fullText
serviceDescription: serviceDescription
responsibleAuthority: responsibleAuthority
Verfahren:
type: object
properties:
verfahrensId:
type: string
leikaId:
type: string
responsibleAuthority:
type: string
statusId:
type: string
statusDescription:
type: string
statusLastChangeDate:
type: string
format: date-time
decisionDate:
type: string
format: date-time
decisionJustification:
type: string
applicant:
$ref: '#/components/schemas/Person'
dataObjects:
type: array
description: List of data objects related to this case, e.g. application
and decision document
items:
$ref: '#/components/schemas/DataObject'
example:
dataObjects:
- dataObjectId: dataObjectId
leikaId: leikaId
verfahrensId: verfahrensId
title: title
type: type
content: {}
- dataObjectId: dataObjectId
leikaId: leikaId
verfahrensId: verfahrensId
title: title
type: type
content: {}
statusDescription: statusDescription
statusLastChangeDate: 2000-01-23T04:56:07.000+00:00
statusId: statusId
leikaId: leikaId
verfahrensId: verfahrensId
decisionJustification: decisionJustification
responsibleAuthority: responsibleAuthority
decisionDate: 2000-01-23T04:56:07.000+00:00
applicant:
address:
zip: zip
country: country
city: city
street: street
houseno: houseno
surname: surname
personId: personId
prename: prename
email: email
DataObject:
type: object
properties:
dataObjectId:
type: string
verfahrensId:
type: string
leikaId:
type: string
title:
type: string
type:
type: string
content:
type: object
example:
dataObjectId: dataObjectId
leikaId: leikaId
verfahrensId: verfahrensId
title: title
type: type
content: {}
Verification:
type: object
properties:
sachverhaltId:
type: string
verificationType:
type: string
verificationDataObject:
$ref: '#/components/schemas/DataObject'
statusId:
type: string
statusDescription:
type: string
statusLastChangeDate:
type: string
format: date-time
approverPerson:
$ref: '#/components/schemas/Person'
example:
sachverhaltId: sachverhaltId
statusDescription: statusDescription
statusLastChangeDate: 2000-01-23T04:56:07.000+00:00
statusId: statusId
verificationType: verificationType
verificationDataObject:
dataObjectId: dataObjectId
leikaId: leikaId
verfahrensId: verfahrensId
title: title
type: type
content: {}
approverPerson:
address:
zip: zip
country: country
city: city
street: street
houseno: houseno
surname: surname
personId: personId
prename: prename
email: email
Person:
type: object
properties:
personId:
type: string
prename:
type: string
surname:
type: string
email:
type: string
address:
$ref: '#/components/schemas/Person_address'
example:
address:
zip: zip
country: country
city: city
street: street
houseno: houseno
surname: surname
personId: personId
prename: prename
email: email
inline_response_200:
properties:
services:
type: array
items:
$ref: '#/components/schemas/Service'
example:
services:
- leikaId: leikaId
fimMasterData: {}
shortText: shortText
fullText: fullText
serviceDescription: serviceDescription
responsibleAuthority: responsibleAuthority
- leikaId: leikaId
fimMasterData: {}
shortText: shortText
fullText: fullText
serviceDescription: serviceDescription
responsibleAuthority: responsibleAuthority
body:
properties:
type:
type: string
document:
$ref: '#/components/schemas/DataObject'
person:
$ref: '#/components/schemas/Person'
Person_address:
type: object
properties:
street:
type: string
houseno:
type: string
zip:
type: string
city:
type: string
country:
type: string
example:
zip: zip
country: country
city: city
street: street
houseno: houseno
'use strict';
var utils = require('../utils/writer.js');
var Application = require('../service/ApplicationService');
module.exports.postCaseApplication = function postCaseApplication (req, res, next, body) {
Application.postCaseApplication(body)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
'use strict';
var utils = require('../utils/writer.js');
var Decision = require('../service/DecisionService');
module.exports.getCaseDecisionDocumentByVerfahrensId = function getCaseDecisionDocumentByVerfahrensId (req, res, next, verfahrensId) {
Decision.getCaseDecisionDocumentByVerfahrensId(verfahrensId)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
'use strict';
var utils = require('../utils/writer.js');
var Info = require('../service/InfoService');
module.exports.getAllServices = function getAllServices (req, res, next) {
Info.getAllServices()
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
module.exports.getServiceByLeiKaId = function getServiceByLeiKaId (req, res, next, leikaId) {
Info.getServiceByLeiKaId(leikaId)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
'use strict';
var utils = require('../utils/writer.js');
var Status = require('../service/StatusService');
module.exports.getCaseByVerfahrensId = function getCaseByVerfahrensId (req, res, next, verfahrensId) {
Status.getCaseByVerfahrensId(verfahrensId)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
'use strict';
var utils = require('../utils/writer.js');
var Verification = require('../service/VerificationService');
module.exports.getVerificationByVerificationId = function getVerificationByVerificationId (req, res, next, sachverhaltId) {
Verification.getVerificationByVerificationId(sachverhaltId)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
module.exports.postVerifcationRequest = function postVerifcationRequest (req, res, next, body) {
Verification.postVerifcationRequest(body)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
'use strict';
var path = require('path');
var http = require('http');
var oas3Tools = require('oas3-tools');
var serverPort = 8080;
// swaggerRouter configuration
var options = {
controllers: path.join(__dirname, './controllers')
};
var expressAppConfig = oas3Tools.expressAppConfig(path.join(__dirname, 'api/openapi.yaml'), options);
expressAppConfig.addValidator();
var app = expressAppConfig.getApp();
// Initialize the Swagger middleware
http.createServer(app).listen(serverPort, function () {
console.log('Your server is listening on port %d (http://localhost:%d)', serverPort, serverPort);
console.log('Swagger-ui is available on http://localhost:%d/docs', serverPort);
});
{
"name": "openapis-f-r-e-government",
"version": "0.0.3",
"description": "This is a sample specification of the interfaces based on a project in the city of Munich for the public sector.",
"main": "index.js",
"scripts": {
"prestart": "npm install",
"start": "node index.js"
},
"keywords": [
"swagger"
],
"license": "Unlicense",
"private": true,
"dependencies": {
"connect": "^3.2.0",
"js-yaml": "^3.3.0",
"oas3-tools": "^2.0.2"
}
}
'use strict';
/**
* Submit a new application including the application documents for an administration case
*
* body Verfahren Application details
* returns Verfahren
**/
exports.postCaseApplication = function(body) {
return new Promise(function(resolve, reject) {
var examples = {};
examples['application/json'] = {
"dataObjects" : [ {
"dataObjectId" : "dataObjectId",
"leikaId" : "leikaId",
"verfahrensId" : "verfahrensId",
"title" : "title",
"type" : "type",
"content" : { }
}, {
"dataObjectId" : "dataObjectId",
"leikaId" : "leikaId",
"verfahrensId" : "verfahrensId",
"title" : "title",
"type" : "type",
"content" : { }
} ],
"statusDescription" : "statusDescription",
"statusLastChangeDate" : "2000-01-23T04:56:07.000+00:00",
"statusId" : "statusId",
"leikaId" : "leikaId",
"verfahrensId" : "verfahrensId",
"decisionJustification" : "decisionJustification",
"responsibleAuthority" : "responsibleAuthority",
"decisionDate" : "2000-01-23T04:56:07.000+00:00",
"applicant" : {
"address" : {
"zip" : "zip",
"country" : "country",
"city" : "city",
"street" : "street",
"houseno" : "houseno"
},
"surname" : "surname",
"personId" : "personId",
"prename" : "prename",
"email" : "email"
}
};
if (Object.keys(examples).length > 0) {
resolve(examples[Object.keys(examples)[0]]);
} else {
resolve();
}
});
}