2. Installed openapi generator with npm: https://openapi-generator.tech/docs/installation/
3. Installed docker (if you want to use it): https://www.docker.com/get-started
# Generate or update the server
In the following, we distinguish between a server code generation from scratch and an update of an existing solution
@@ -11,7 +18,6 @@ In the following, we distinguish between a server code generation from scratch a
---
# First generation
We provide a zip-file `additions.zip` with a folder structure and some files to simplify your work.
If you want to use it unpack `additions.zip` in this folder and continue with the instruction for an [update](#update).
@@ -30,7 +36,6 @@ The zip-file additions.zip contains:
* server/data/ - empty folder for the databases of MongoDB
* server/.openapi-generator-ignore - to prevent openapi-generator to override these files
## auto-generate server code
open a command shell and execute
```
@@ -45,7 +50,7 @@ add the following file and folder entries:
**/Startup.cs
**/appsettings.json
**/Dockerfile
**/docker-compoese.yml
**/docker-compose.yml
**/.openapi-generator-ignore
**/ControllersImpl
@@ -58,12 +63,10 @@ add the following file and folder entries:
## In Visual Studio:
open `NuGet Package Manager` and add `MongoDB.Driver`
### - folder `Controllers`:
copy all files from `Controllers` to `ControllersImpl`
In all files in the folder `Controllers` change `public class` to `public abstract class`
### - folder `ControllersImpl`:
change classnames by appending `Impl` to the original classnames (and change filenames accordingly) and inherit from original class in `Controllers`
create a folder `ControllersImpl` and copy all files from `Controllers` to `ControllersImpl`
change classnames by appending `Impl` to the original classnames (and change filenames accordingly) and inherit from original class in `Controllers` (instead of `ControllerBase`)
and replace `virtual` by `override` with all methods.
@@ -87,6 +90,10 @@ Add a constructor with this service class variable, e.g.
```
remove sample code and replace it by using the appropriate methods of the corresponding classes in the folder `Services`
(have a look into the above mentioned `additions.zip` for an example)
### - folder `Controllers`:
In all files in the folder `Controllers` change `public class` to `public abstract class`
### - folder `Models`:
in the files add:
@@ -102,7 +109,9 @@ at the value that is to become the Database ID, add:
```
### - folder `Services`
contains one class with the DatabaseSettings and one with the database-access-methods (create, get, update, remove) for each API
create the folder `Services` and have a look into the above mentioned `additions.zip` for an example
the folder `Services` should contain one class with the DatabaseSettings and one with the database-access-methods (create, get, update, remove) for each API
the naming in the DatabaseSettings is the same as defined in `appsettings.json `
@@ -158,7 +167,6 @@ if you don't have a MongoDB add the folders
and put MongoDB in folder `server/programs/MongoDB` (download MongoDB as zip-file from https://www.mongodb.com/try/download/community and unzip the file into this directory, so that the bin-directory is in this folder)
---
# Update
@@ -207,6 +215,15 @@ open a command shell and generate docker by executing in `server/src/Org.OpenAPI
```
## to start:
the easiest way is to use docker-compose:
if not already done (i.e. by using the above mentioned zip-file `additions.zip`):
* copy file `docker-compose.yml` and folder `docker` from the above mentioned zip-file `additions.zip` or
* create a folder `docker`
* create a sub-folder `data-dump`
* copy appsettings.json into the folder `docker` and adapt the connectionString for MongoDB for the usage in docker
* create a file docker-compose.yml for the above created image and MongoDB-image or copy it from the above mentioned zip-file `additions.zip`
open a command shell and use docker-compose (if necessary adapt docker-compose.yml) by executing in `server/src/Org.OpenAPITools`: