The interior of a component consists of one or more blocks, with a block of type RESTfulService being the predominant architectural element. The RESTfulService consists of a set of stateless operations used to read, create, or modify content. Each operation has a http call, a reference to a source code file, a response scheme, and a request scheme. Several selected operations are published and tested via one port as REST API. The model-based implementation of the architecture is thus based on block diagrams and takes place through directories that contain source code files. By default, you edit the source code files in objectiF RM using Visual Studio code.
Create code file
The architecture is implemented via source code files. You can create the files in a directory of your choice.
- Select the Create / Import File command from the context menu of a directory. Alternatively, you can drag and drop a file or an entire directory into an existing directory.
Assign code directory to block
You model the architecture using block diagrams that contain one or more blocks. The individual blocks are to implement the desired requirements later. The conversion takes place via source code files, which are edited in Visual Studio Code. For this reason, you can specify an implementation directory for each block that contains the files required for the implementation.
- Create a block using Create / Block or edit a block using the context menu command Edit.
- Under Sourcecode you can specify a directory with several files or a file by clicking the […] button.
- Save the block with OK.
If you do not want to create a block with the associated directories and code files manually, you can use the pattern Create Block for RESTful Service. This creates a block that has links to an implementation directory. This directory contains additional subdirectories for the code of operations and the schemas. Code snippets are also created – for the block as well as for the operation created.
Assign code file to an operation
You can create operations for a block that are used for reading, creating, or editing. Each operation has an HTTP verb, a URL for calling and references to a code file, and a request and response schema in JSON notation.
- Select the Create / Operation command from the context menu of a block or edit one using the Edit context menu command.
- An operation requires a request and a response schema that define which data is to be edited and returned.
- Under Sourcecode, use the […] button to specify a file that is to be executed.
- Save the operation with OK.
You can edit, test, and return individual files or a directory with multiple files.
- From the context menu of a directory or file, select Open [Directory] in VS Code.
- Click OK in the dialog that opens. If necessary, you can change the working directory. The file is checked out and opened in Visual Studio Code. The directory structure corresponds to that in objectiF RM.
- Edit the file by clicking on it. To the right of it appears the code, which you can now edit.
- Save and close the file.