Convert Swagger or OpenAPI Specs to Spring Boot REST API

- - posted in Technical | Tagged as swagger,openapi,springboot,spring | Comments

What is Swagger? Swagger allows you to describe the structure of your APIs so that machines can read them. The ability of APIs to describe their own structure is the root of all awesomeness in Swagger.

  1. Open https://editor.swagger.io/
  2. Select File -> Import URL
  3. Enter any of these URL and you would be able to see compelete spec in a clearly understandable format.
    API ServiceOrdering 4.0.0 [ Base URL: serverRoot/tmf-api/serviceOrdering/v4 ]
    Federated ID 4.0 [ Base URL: serverRoot/tmf-api/openid/v4 ]
    Communication Management API 4.0.0 [ Base URL: serverRoot/tmf-api/communicationManagement/v4/ ]

You would notice how OpenAPI/Swagger Specification helps understand the API and agree on its attributes. In this post I am going to show how we can generate code and documentation from the specification file.

Let's generate the code create an empty maven project named "TMF-ApiSpec"

There are several ways to generate the code from a swagger json/yaml spec.
For e.g. You can download openapi-generator-cli-4.2.3.jar and use the generate command.

1
java -cp . -jar openapi-generator-cli-4.2.3.jar generate -i TMF641-ServiceOrdering-3.0.0.swagger.json --api-package com.cts.serviceorder.client.api --model-package com.cts.serviceorder.client.model --invoker-package com.cts.serviceorder.client.invoker --group-id com.cts --artifact-id spring-openapi-generator-api-client --artifact-version 0.0.1-SNAPSHOT -g java -p java8=true --library resttemplate -o openapi-serviceorder

See more about generate and help

You can also use online service to generate the code:

1
curl -X POST -H "content-type:application/json" -d '{"openAPIUrl":"https://github.com/tmforum-apis/TMF641_ServiceOrder/releases/download/v3.0.0/TMF641-ServiceOrdering-3.0.0.swagger.json"}' http://api.openapi-generator.tech/api/gen/clients/java

I am using the plugin

For the API spec I am using TMForum's ServiceOrderingManagement OpenAPI specification. You can choose one of Yaml or Json format

Update the pom.xml File:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.ashwani</groupId>
  <artifactId>TMF-ApiSpec</artifactId>
  <version>0.0.1-SNAPSHOT</version>
 
    <properties>
        <swagger-annotations-version>1.5.22</swagger-annotations-version>
        <jersey-version>2.27</jersey-version>
        <jackson-version>2.8.9</jackson-version>
        <jodatime-version>2.7</jodatime-version>
        <maven-plugin-version>1.0.0</maven-plugin-version>
        <junit-version>4.8.1</junit-version>
        <springfox-version>2.9.2</springfox-version>
        <threetenbp-version>1.3.8</threetenbp-version>
        <datatype-threetenbp-version>2.6.4</datatype-threetenbp-version>
        <spring-boot-starter-test-version>2.1.1.RELEASE</spring-boot-starter-test-version>
        <spring-boot-starter-web-version>2.1.0.RELEASE</spring-boot-starter-web-version>
        <junit-version>4.12</junit-version>
        <migbase64-version>2.2</migbase64-version>
    </properties>
 
    <dependencies>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>${swagger-annotations-version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>${jersey-version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-multipart</artifactId>
            <version>${jersey-version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>${jersey-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.jaxrs</groupId>
            <artifactId>jackson-jaxrs-base</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.jaxrs</groupId>
            <artifactId>jackson-jaxrs-json-provider</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-joda</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>${jodatime-version}</version>
        </dependency>
        <dependency>
            <groupId>com.brsanthu</groupId>
            <artifactId>migbase64</artifactId>
            <version>${migbase64-version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit-version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>${spring-boot-starter-test-version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>${spring-boot-starter-web-version}</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>${springfox-version}</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>${springfox-version}</version>
        </dependency>
        <dependency>
            <groupId>org.threeten</groupId>
            <artifactId>threetenbp</artifactId>
            <version>${threetenbp-version}</version>
        </dependency>
        <dependency>
            <groupId>com.github.joschi.jackson</groupId>
            <artifactId>jackson-datatype-threetenbp</artifactId>
            <version>${datatype-threetenbp-version}</version>
        </dependency>
    </dependencies>
 
    <build>
        <plugins>
            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>3.3.4</version>
                <executions>
                    <execution>
                        <id>spring-boot-api</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/src/main/resources/TMF641-Service_Ordering-v4.0.0.swagger.json</inputSpec>
                            <generatorName>spring</generatorName>
                            <configOptions>
                                <dateLibrary>joda</dateLibrary>
                            </configOptions>
                            <library>spring-boot</library>
                            <apiPackage>com.ashwani.demo.api</apiPackage>
                            <modelPackage>com.ashwani.demo.api.model</modelPackage>
                            <invokerPackage>com.ashwani.demo.api.handler</invokerPackage>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.1</version>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Execute MVN install in the root directory of the project. And the resulting code would be generated by openapi-generator-maven-plugin in target/generated-sources/. com.ashwani.demo.api. Various generators based on your preference.

Swagger Code generation directory structure


Now let's create a new spring boot project demo-service from https://start.spring.io/. Once a bare spring boot project is created with Spring Web dependency. Now add the Maven dependency in this spring project.

1
2
3
4
5
6
7
<dependency>
              <groupId>com.ashwani</groupId>
              <artifactId>openapi-serviceorder-client</artifactId>
          <version>0.0.1-SNAPSHOT</version>
          <scope>system</scope>
          <systemPath>${basedir}/lib/TMF-ApiSpec-0.0.1-SNAPSHOT.jar</systemPath>
      </dependency>

With the other dependecies for this project , the pom.xml should look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.3.2.RELEASE</version>
      <relativePath/> <!-- lookup parent from repository -->
  </parent>
  <groupId>com.ashwani</groupId>
  <artifactId>TMF-OpenAPISim</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>TMF-OpenAPISim</name>
  <description>Spring Boot - TMF-OpenAPISim</description>

    <properties>
        <java.version>9</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <springfox-version>2.8.0</springfox-version>
    </properties>

  <dependencies>
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
        <!--SpringFox dependencies -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>${springfox-version}</version>
        </dependency>
        <dependency>
          <groupId>javax.xml.bind</groupId>
          <artifactId>jaxb-api</artifactId>
          <version>2.3.0</version>
      </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>${springfox-version}</version>
        </dependency>
        
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-joda</artifactId>
        </dependency>
            <!-- Bean Validation API support -->
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
        </dependency>
        
                  <dependency>
                <groupId>com.github.joschi.jackson</groupId>
                <artifactId>jackson-datatype-threetenbp</artifactId>
                <version>2.9.10</version>
            </dependency>
      <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-test</artifactId>
          <scope>test</scope>
          <exclusions>
              <exclusion>
                  <groupId>org.junit.vintage</groupId>
                  <artifactId>junit-vintage-engine</artifactId>
              </exclusion>
          </exclusions>
      </dependency>
      
      <dependency>
          <groupId>com.ashwani</groupId>
          <artifactId>openapi-serviceorder-client</artifactId>
          <version>0.0.1-SNAPSHOT</version>
          <scope>system</scope>
          <systemPath>${basedir}/lib/TMF-ApiSpec-0.0.1-SNAPSHOT.jar</systemPath>
      </dependency>
      <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>${springfox-version}</version>
        </dependency>
      
  </dependencies>

  <build>
      <plugins>
          <plugin>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-maven-plugin</artifactId>
          </plugin>
      </plugins>
  </build>

</project>


Now create a class ServiceOrderApiController which will implement previously generated ServiceOrderApi from previous step. And make some implementation of the API:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.ashwani.serviceorder.api;

import java.security.Principal;
import java.util.Optional;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.threeten.bp.OffsetDateTime;

import com.ashwani.serviceorder.api.model.Error;
import com.ashwani.serviceorder.api.model.RelatedParty;
import com.ashwani.serviceorder.api.model.ServiceOrder;
import com.ashwani.serviceorder.api.model.ServiceOrderCreate;
import com.ashwani.serviceorder.api.model.ServiceOrderItem;
import com.ashwani.serviceorder.api.model.ServiceRestriction;
import com.ashwani.serviceorder.api.ServiceOrderRepoService;


import com.fasterxml.jackson.databind.ObjectMapper;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2020-07-25T00:30:31.539259300+01:00[Europe/London]")

@Controller
@RequestMapping("${openapi.aPIServiceOrdering.base-path:/tmf-api/serviceOrdering/v3}")
public class ServiceOrderApiController implements ServiceOrderApi {

  private static final Logger logger = LoggerFactory.getLogger(ServiceOrderApiController.class);

  private final ObjectMapper objectMapper;

  private final HttpServletRequest request;
  
  @Autowired
  ServiceOrderRepoService serviceOrderRepoService;

  
    @Autowired
  public ServiceOrderApiController(ObjectMapper objectMapper, HttpServletRequest request) {
      this.objectMapper = objectMapper;
      this.request = request;
  }

    @ApiOperation(value = "Creates a ServiceOrder", nickname = "createServiceOrder", notes = "This operation creates a ServiceOrder entity.", response = ServiceOrder.class, tags={ "serviceOrder", })
    @ApiResponses(value = { 
        @ApiResponse(code = 201, message = "Created", response = ServiceOrder.class),
        @ApiResponse(code = 400, message = "Bad Request", response = Error.class),
        @ApiResponse(code = 401, message = "Unauthorized", response = Error.class),
        @ApiResponse(code = 403, message = "Forbidden", response = Error.class),
        @ApiResponse(code = 405, message = "Method Not allowed", response = Error.class),
        @ApiResponse(code = 409, message = "Conflict", response = Error.class),
        @ApiResponse(code = 500, message = "Internal Server Error", response = Error.class) })
    @RequestMapping(value = "/serviceOrder",
        produces = { "application/json;charset=utf-8" }, 
        consumes = { "application/json;charset=utf-8" },
        method = RequestMethod.POST)
    public ResponseEntity<ServiceOrder> createServiceOrder(@ApiParam(value = "The ServiceOrder to be created" ,required=true )  @Valid @RequestBody ServiceOrderCreate serviceOrderCreate) {
        ServiceOrderCreate soc = serviceOrderCreate;
        
            try {
                  System.out.println(serviceOrderCreate.toString());
                  ServiceOrder c = serviceOrderRepoService.addServiceOrder(soc);
                  return new ResponseEntity<ServiceOrder>(c, HttpStatus.OK);               

          }catch (Exception e) {
              e.printStackTrace();
              return new ResponseEntity<ServiceOrder>(HttpStatus.INTERNAL_SERVER_ERROR);
          }
    }
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.ashwani.serviceorder.api;


import java.util.Date;
import java.util.Set;

import javax.validation.Valid;

import org.joda.time.DateTime;
import org.springframework.stereotype.Service;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZoneOffset;

import com.ashwani.serviceorder.api.model.Any;
import com.ashwani.serviceorder.api.model.Characteristic;
import com.ashwani.serviceorder.api.model.ServiceOrder;
import com.ashwani.serviceorder.api.model.ServiceOrderAttributeValueChangeEvent;
import com.ashwani.serviceorder.api.model.ServiceOrderAttributeValueChangeNotification;
import com.ashwani.serviceorder.api.model.ServiceOrderCreate;
import com.ashwani.serviceorder.api.model.ServiceOrderItem;
import com.ashwani.serviceorder.api.model.ServiceOrderStateChangeEvent;
import com.ashwani.serviceorder.api.model.ServiceOrderStateChangeNotification;
import com.ashwani.serviceorder.api.model.ServiceOrderStateType;

@Service
public class ServiceOrderRepoService {

  public ServiceOrder addServiceOrder(@Valid ServiceOrderCreate serviceOrderCreate) {
      ServiceOrder so = new ServiceOrder();
      DateTime d = DateTime.now();
      so.setOrderDate(d);
      so.setCategory(serviceOrderCreate.getCategory());
      so.setDescription(serviceOrderCreate.getDescription());
      so.setExternalId(serviceOrderCreate.getExternalId());
      so.setNotificationContact(serviceOrderCreate.getNotificationContact());
      so.priority(serviceOrderCreate.getPriority());
      so.requestedCompletionDate(serviceOrderCreate.getRequestedCompletionDate());
      so.requestedStartDate(serviceOrderCreate.getRequestedStartDate());
      so.setExpectedCompletionDate(serviceOrderCreate.getRequestedCompletionDate()); // this is by default
      if (serviceOrderCreate.getNote() != null) {
          //so.getNote().addAll(serviceOrderCreate.getNote()); // --> This works with v3 of TMF Specification
          so.setNote(serviceOrderCreate.getNote());
      }

      boolean allAcknowledged = true;
      //if (serviceOrderCreate.getOrderItem() != null) { //--> This works with v3 of TMF Specification
          //so.getOrderItem().addAll(serviceOrderCreate.getOrderItem()); // --> This works with v3 of TMF Specification
          //for (ServiceOrderItem soi : so.getOrderItem()) {


      if (serviceOrderCreate.getServiceOrderItem() != null) {
          so.setServiceOrderItem(serviceOrderCreate.getServiceOrderItem());
          for (ServiceOrderItem soi : so.getServiceOrderItem()) { 
              //copySpecCharacteristicsToServiceCharacteristic(soi.getService().getServiceSpecification().getId(),
              //      soi.getService().getServiceCharacteristic());
              
              System.out.println("SOI --> " + soi.toString());
              
              if (soi.getState()!= null && !soi.getState().equals(ServiceOrderStateType.ACKNOWLEDGED)) {
                  allAcknowledged = false;
              }
          }

      }

      if (serviceOrderCreate.getRelatedParty() != null) {
          //so.getRelatedParty().addAll(serviceOrderCreate.getRelatedParty()); // --> This works with v3 of TMF Specification
          so.setRelatedParty(serviceOrderCreate.getRelatedParty());
      }
      if (serviceOrderCreate.getOrderRelationship() != null) {
          //so.getOrderRelationship().addAll(serviceOrderCreate.getOrderRelationship()); // --> This works with v3 of TMF Specification
          so.setOrderRelationship(serviceOrderCreate.getOrderRelationship());
      }


      // so = this.serviceOrderRepo.save(so);  You can save this in DB.

      if (allAcknowledged) { // in the case were order items are automatically acknowledged
          so.setState(ServiceOrderStateType.ACKNOWLEDGED);
          d = DateTime.now();
          so.setOrderDate(d);
          //so = this.serviceOrderRepo.save(so);
      }

      //raiseSOCreateNotification(so);

      return so;
  }
  
}

Now we can test the server. Send a request from postman on following end point. http://localhost:8080/tmf-api/serviceOrdering/v3/serviceOrder

Request Body
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
{
  "cancellationDate": "2020-08-08T11:55:14.450Z",
  "cancellationReason": "string",
  "category": "string",
  "description": "string",
  "externalId": "string",
  "notificationContact": "string",
  "priority": "string",
  "requestedCompletionDate": "2020-08-08T11:55:14.450Z",
  "requestedStartDate": "2020-08-08T11:55:14.450Z",
  "externalReference": [
    {
      "externalReferenceType": "string",
      "name": "string",
      "@baseType": "string",
      "@schemaLocation": "string",
      "@type": "string"
    }
  ],
  "note": [
    {
      "id": "string",
      "author": "string",
      "date": "2020-08-08T11:55:14.450Z",
      "text": "string",
      "@baseType": "string",
      "@schemaLocation": "string",
      "@type": "string"
    }
  ],
  "orderRelationship": [
    {
      "id": "string",
      "href": "string",
      "relationshipType": "string",
      "@baseType": "string",
      "@schemaLocation": "string",
      "@type": "string",
      "@referredType": "string"
    }
  ],
  "relatedParty": [
    {
      "id": "string",
      "href": "string",
      "name": "string",
      "role": "string",
      "@baseType": "ResourceSpecification",
      "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
      "@type": "LogicalResourceSpecification",
      "@referredType": "string"
    }
  ],
  "serviceOrderItem": [
    {
      "id": "string",
      "quantity": 0,
      "action": "add",
      "appointment": {
        "id": "string",
        "href": "string",
        "description": "string",
        "@baseType": "string",
        "@schemaLocation": "string",
        "@type": "string",
        "@referredType": "string"
      },
      "service": {
        "id": "string",
        "href": "string",
        "category": "string",
        "description": "string",
        "endDate": "2020-08-08T11:55:14.450Z",
        "hasStarted": true,
        "isBundle": true,
        "isServiceEnabled": true,
        "isStateful": true,
        "name": "string",
        "serviceDate": "string",
        "serviceType": "string",
        "startDate": "2020-08-08T11:55:14.450Z",
        "startMode": "string",
        "feature": [
          {
            "id": "string",
            "isBundle": true,
            "isEnabled": true,
            "name": "string",
            "constraint": [
              {
                "id": "string",
                "href": "string",
                "name": "string",
                "version": "string",
                "@baseType": "string",
                "@schemaLocation": "string",
                "@type": "string",
                "@referredType": "string"
              }
            ],
            "featureCharacteristic": [
              {
                "id": "string",
                "name": "string",
                "valueType": "string",
                "characteristicRelationship": [
                  {
                    "id": "string",
                    "relationshipType": "string",
                    "@baseType": "string",
                    "@schemaLocation": "string",
                    "@type": "string"
                  }
                ],
                "@baseType": "ResourceSpecification",
                "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
                "@type": "LogicalResourceSpecification"
              }
            ],
            "featureRelationship": [
              {
                "id": "string",
                "name": "string",
                "relationshipType": "string",
                "validFor": {
                  "endDateTime": "1985-04-12T23:20:50.52Z",
                  "startDateTime": "1985-04-12T23:20:50.52Z",
                  "@baseType": "string",
                  "@schemaLocation": "string",
                  "@type": "string"
                },
                "@baseType": "string",
                "@schemaLocation": "string",
                "@type": "string"
              }
            ],
            "@baseType": "string",
            "@schemaLocation": "string",
            "@type": "string"
          }
        ],
        "note": [
          {
            "id": "string",
            "author": "string",
            "date": "2020-08-08T11:55:14.450Z",
            "text": "string",
            "@baseType": "string",
            "@schemaLocation": "string",
            "@type": "string"
          }
        ],
        "place": [
          {
            "id": "string",
            "href": "string",
            "name": "string",
            "role": "string",
            "@baseType": "ResourceSpecification",
            "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
            "@type": "LogicalResourceSpecification",
            "@referredType": "string"
          }
        ],
        "relatedEntity": [
          {
            "id": "string",
            "href": "string",
            "name": "string",
            "role": "string",
            "@baseType": "ResourceSpecification",
            "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
            "@type": "LogicalResourceSpecification",
            "@referredType": "string"
          }
        ],
        "relatedParty": [
          {
            "id": "string",
            "href": "string",
            "name": "string",
            "role": "string",
            "@baseType": "ResourceSpecification",
            "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
            "@type": "LogicalResourceSpecification",
            "@referredType": "string"
          }
        ],
        "serviceCharacteristic": [
          {
            "id": "string",
            "name": "string",
            "valueType": "string",
            "characteristicRelationship": [
              {
                "id": "string",
                "relationshipType": "string",
                "@baseType": "string",
                "@schemaLocation": "string",
                "@type": "string"
              }
            ],
            "@baseType": "ResourceSpecification",
            "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
            "@type": "LogicalResourceSpecification"
          }
        ],
        "serviceOrderItem": [
          {
            "itemId": "string",
            "role": "string",
            "serviceOrderHref": "string",
            "serviceOrderId": "string",
            "itemAction": "add",
            "@baseType": "string",
            "@schemaLocation": "string",
            "@type": "string",
            "@referredType": "string"
          }
        ],
        "serviceRelationship": [
          {
            "relationshipType": "string",
            "serviceRelationshipCharacteristic": [
              {
                "id": "string",
                "name": "string",
                "valueType": "string",
                "characteristicRelationship": [
                  {
                    "id": "string",
                    "relationshipType": "string",
                    "@baseType": "string",
                    "@schemaLocation": "string",
                    "@type": "string"
                  }
                ],
                "@baseType": "ResourceSpecification",
                "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
                "@type": "LogicalResourceSpecification"
              }
            ],
            "@baseType": "string",
            "@schemaLocation": "string",
            "@type": "string"
          }
        ],
        "serviceSpecification": {
          "id": "string",
          "href": "string",
          "name": "string",
          "version": "string",
          "@baseType": "ResourceSpecification",
          "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
          "@type": "LogicalResourceSpecification",
          "@referredType": "string"
        },
        "state": "feasibilityChecked",
        "supportingResource": [
          {
            "id": "string",
            "href": "string",
            "name": "string",
            "@baseType": "ResourceSpecification",
            "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
            "@type": "LogicalResourceSpecification",
            "@referredType": "string"
          }
        ],
        "supportingService": [
          null
        ],
        "@baseType": "ResourceSpecification",
        "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
        "@type": "LogicalResourceSpecification",
        "@referredType": "string"
      },
      "serviceOrderItem": [
        null
      ],
      "serviceOrderItemRelationship": [
        {
          "relationshipType": "string",
          "orderItem": {
            "itemId": "string",
            "serviceOrderHref": "string",
            "serviceOrderId": "string",
            "@baseType": "ResourceSpecification",
            "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
            "@type": "LogicalResourceSpecification",
            "@referredType": "string"
          },
          "@baseType": "ResourceSpecification",
          "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
          "@type": "LogicalResourceSpecification"
        }
      ],
      "state": "acknowledged",
      "@baseType": "ResourceSpecification",
      "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
      "@type": "LogicalResourceSpecification"
    }
  ],
  "@baseType": "string",
  "@schemaLocation": "string",
  "@type": "string"
}

If all goes well you will get the following response:

Response Body
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
{
    "id": null,
    "href": null,
    "cancellationDate": null,
    "cancellationReason": null,
    "category": "string",
    "completionDate": null,
    "description": "string",
    "expectedCompletionDate": "2020-08-08T11:55:14.450Z",
    "externalId": "string",
    "notificationContact": "string",
    "orderDate": "2020-08-08T12:16:55.457Z",
    "priority": "string",
    "requestedCompletionDate": "2020-08-08T11:55:14.450Z",
    "requestedStartDate": "2020-08-08T11:55:14.450Z",
    "startDate": null,
    "externalReference": null,
    "note": [
        {
            "id": "string",
            "author": "string",
            "date": "2020-08-08T11:55:14.450Z",
            "text": "string",
            "@baseType": "string",
            "@schemaLocation": "string",
            "@type": "string"
        }
    ],
    "orderRelationship": [
        {
            "id": "string",
            "href": "string",
            "relationshipType": "string",
            "@baseType": "string",
            "@schemaLocation": "string",
            "@type": "string",
            "@referredType": "string"
        }
    ],
    "relatedParty": [
        {
            "id": "string",
            "href": "string",
            "name": "string",
            "role": "string",
            "@baseType": "ResourceSpecification",
            "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
            "@type": "LogicalResourceSpecification",
            "@referredType": "string"
        }
    ],
    "serviceOrderItem": [
        {
            "id": "string",
            "quantity": 0,
            "action": "add",
            "appointment": {
                "id": "string",
                "href": "string",
                "description": "string",
                "@baseType": "string",
                "@schemaLocation": "string",
                "@type": "string",
                "@referredType": "string"
            },
            "service": {
                "id": "string",
                "href": "string",
                "category": "string",
                "description": "string",
                "endDate": "2020-08-08T11:55:14.450Z",
                "hasStarted": true,
                "isBundle": true,
                "isServiceEnabled": true,
                "isStateful": true,
                "name": "string",
                "serviceDate": "string",
                "serviceType": "string",
                "startDate": "2020-08-08T11:55:14.450Z",
                "startMode": "string",
                "feature": [
                    {
                        "id": "string",
                        "isBundle": true,
                        "isEnabled": true,
                        "name": "string",
                        "constraint": [
                            {
                                "id": "string",
                                "href": "string",
                                "name": "string",
                                "version": "string",
                                "@baseType": "string",
                                "@schemaLocation": "string",
                                "@type": "string",
                                "@referredType": "string"
                            }
                        ],
                        "featureCharacteristic": [
                            {
                                "id": "string",
                                "name": "string",
                                "valueType": "string",
                                "characteristicRelationship": [
                                    {
                                        "id": "string",
                                        "relationshipType": "string",
                                        "@baseType": "string",
                                        "@schemaLocation": "string",
                                        "@type": "string"
                                    }
                                ],
                                "value": null,
                                "@baseType": "ResourceSpecification",
                                "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
                                "@type": "LogicalResourceSpecification"
                            }
                        ],
                        "featureRelationship": [
                            {
                                "id": "string",
                                "name": "string",
                                "relationshipType": "string",
                                "validFor": {
                                    "endDateTime": "1985-04-12T23:20:50.520Z",
                                    "startDateTime": "1985-04-12T23:20:50.520Z",
                                    "@baseType": "string",
                                    "@schemaLocation": "string",
                                    "@type": "string"
                                },
                                "@baseType": "string",
                                "@schemaLocation": "string",
                                "@type": "string"
                            }
                        ],
                        "@baseType": "string",
                        "@schemaLocation": "string",
                        "@type": "string"
                    }
                ],
                "note": [
                    {
                        "id": "string",
                        "author": "string",
                        "date": "2020-08-08T11:55:14.450Z",
                        "text": "string",
                        "@baseType": "string",
                        "@schemaLocation": "string",
                        "@type": "string"
                    }
                ],
                "place": [
                    {
                        "id": "string",
                        "href": "string",
                        "name": "string",
                        "role": "string",
                        "@baseType": "ResourceSpecification",
                        "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
                        "@type": "LogicalResourceSpecification",
                        "@referredType": "string"
                    }
                ],
                "relatedEntity": [
                    {
                        "id": "string",
                        "href": "string",
                        "name": "string",
                        "role": "string",
                        "@baseType": "ResourceSpecification",
                        "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
                        "@type": "LogicalResourceSpecification",
                        "@referredType": "string"
                    }
                ],
                "relatedParty": [
                    {
                        "id": "string",
                        "href": "string",
                        "name": "string",
                        "role": "string",
                        "@baseType": "ResourceSpecification",
                        "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
                        "@type": "LogicalResourceSpecification",
                        "@referredType": "string"
                    }
                ],
                "serviceCharacteristic": [
                    {
                        "id": "string",
                        "name": "string",
                        "valueType": "string",
                        "characteristicRelationship": [
                            {
                                "id": "string",
                                "relationshipType": "string",
                                "@baseType": "string",
                                "@schemaLocation": "string",
                                "@type": "string"
                            }
                        ],
                        "value": null,
                        "@baseType": "ResourceSpecification",
                        "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
                        "@type": "LogicalResourceSpecification"
                    }
                ],
                "serviceOrderItem": [
                    {
                        "itemId": "string",
                        "role": "string",
                        "serviceOrderHref": "string",
                        "serviceOrderId": "string",
                        "itemAction": "add",
                        "@baseType": "string",
                        "@schemaLocation": "string",
                        "@type": "string",
                        "@referredType": "string"
                    }
                ],
                "serviceRelationship": [
                    {
                        "relationshipType": "string",
                        "service": null,
                        "serviceRelationshipCharacteristic": [
                            {
                                "id": "string",
                                "name": "string",
                                "valueType": "string",
                                "characteristicRelationship": [
                                    {
                                        "id": "string",
                                        "relationshipType": "string",
                                        "@baseType": "string",
                                        "@schemaLocation": "string",
                                        "@type": "string"
                                    }
                                ],
                                "value": null,
                                "@baseType": "ResourceSpecification",
                                "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
                                "@type": "LogicalResourceSpecification"
                            }
                        ],
                        "@baseType": "string",
                        "@schemaLocation": "string",
                        "@type": "string"
                    }
                ],
                "serviceSpecification": {
                    "id": "string",
                    "href": "string",
                    "name": "string",
                    "version": "string",
                    "@baseType": "ResourceSpecification",
                    "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
                    "@type": "LogicalResourceSpecification",
                    "@referredType": "string"
                },
                "state": "feasibilityChecked",
                "supportingResource": [
                    {
                        "id": "string",
                        "href": "string",
                        "name": "string",
                        "@baseType": "ResourceSpecification",
                        "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
                        "@type": "LogicalResourceSpecification",
                        "@referredType": "string"
                    }
                ],
                "supportingService": [
                    null
                ],
                "@baseType": "ResourceSpecification",
                "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
                "@type": "LogicalResourceSpecification",
                "@referredType": "string"
            },
            "serviceOrderItem": [
                null
            ],
            "serviceOrderItemRelationship": [
                {
                    "relationshipType": "string",
                    "orderItem": {
                        "itemId": "string",
                        "serviceOrderHref": "string",
                        "serviceOrderId": "string",
                        "@baseType": "ResourceSpecification",
                        "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
                        "@type": "LogicalResourceSpecification",
                        "@referredType": "string"
                    },
                    "@baseType": "ResourceSpecification",
                    "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
                    "@type": "LogicalResourceSpecification"
                }
            ],
            "state": "acknowledged",
            "@baseType": "ResourceSpecification",
            "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/LogicalResourceSpecification.schema.json",
            "@type": "LogicalResourceSpecification"
        }
    ],
    "state": null,
    "@baseType": null,
    "@schemaLocation": null,
    "@type": null
}

Next steps:

To add persistent to the order creation etc. Something similar to this

Few References:

Swagger-codegen/ Swagger Editor online TMForum OpenAPI Table openapi-generator-maven-plugin Swagger UI-Once you generate the code, it also generates a swagger UI openslice TMForum Datamodel





Gravatar of Ashwani Kumar

Recent posts


Subscribe



Your Feedback encourages me




Learning and Developments

One Month Rails



, 2FA, AWS AWS, Active Authenticator Directory, Facebook Flash, Forwarding, GOD,Chat,Coffee Github,Feedback,Repo Google Google,Search HAProxy, IOT, IP-block JQuery LetsEncrypt Load MQ MQTT, Messaging Octopress Octopress, OpenVpn OpenVpn, PI, Plugin Plugin, Port Raspberry, S3, SSH, Shell,Commands Soapui, Tag Tag, Tree, Tunneling XML XML, XServer, Xming ajax, angular, animated architecture, balancing cloud, commenting, connectivity datatables diagrams diaspora dropdown geocoding grep, hashicorp, ipaddress, ipv6, java, java,python mysql nokogiri, octopress-migration octopress-plugin openapi, openssl powershell proxy rails, repo reviews ruby, script scripts, security, sharepoint shell spring springboot, ssh, swagger, telnet, vault vi, vieditor vim, visualblock, webattacks windows,cleanup windowsxp