Adapt API to OpenApiObject removal
[netconf.git] / restconf / restconf-openapi / src / main / java / org / opendaylight / restconf / openapi / model / InfoEntity.java
1 /*
2  * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.openapi.model;
9
10 import com.fasterxml.jackson.core.JsonGenerator;
11 import java.io.IOException;
12 import org.eclipse.jdt.annotation.NonNull;
13
14 public final class InfoEntity extends OpenApiEntity {
15     private final String title;
16     private static final String DESCRIPTION = """
17         We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).
18         For operational data we only provide GET API.\n
19         For majority of request you can see only config data in examples. That is because we can show only one example
20         per request. The exception when you can see operational data in example is when data are representing
21         operational (config false) container with no config data in it.""";
22
23     public InfoEntity(final String title) {
24         this.title = title;
25     }
26
27     @Override
28     public void generate(@NonNull JsonGenerator generator) throws IOException {
29         generator.writeObjectFieldStart("info");
30         generator.writeStringField("version", "1.0.0");
31         if (title != null) {
32             generator.writeStringField("title", title);
33         }
34         generator.writeStringField("description", DESCRIPTION);
35         generator.writeEndObject();
36     }
37 }