2 * Copyright (c) 2023 PANTHEON.tech s.r.o and others. All rights reserved.
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
8 package org.opendaylight.restconf.openapi.model;
10 import com.fasterxml.jackson.core.JsonGenerator;
11 import java.io.IOException;
12 import java.util.Objects;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.eclipse.jdt.annotation.Nullable;
16 public final class PathEntity extends OpenApiEntity {
17 private final @NonNull String path;
18 private final @Nullable PostEntity post;
19 private final @Nullable PatchEntity patch;
20 private final @Nullable GetEntity get;
21 private final @Nullable PutEntity put;
22 private final @Nullable DeleteEntity delete;
24 public PathEntity(final String path, final PostEntity post, final PatchEntity patch,
25 final PutEntity put, final GetEntity get, final DeleteEntity delete) {
26 this.path = Objects.requireNonNull(path);
35 public void generate(@NonNull JsonGenerator generator) throws IOException {
36 generator.writeObjectFieldStart(path);
37 final var ref = ref();
39 generator.writeStringField("$ref", ref);
41 final var summary = summary();
42 if (summary != null) {
43 generator.writeStringField("summary", summary);
45 final var description = description();
47 generator.writeStringField("description", description);
49 final var postOperation = post();
50 if (postOperation != null) {
51 postOperation.generate(generator);
53 final var putOperation = put();
54 if (putOperation != null) {
55 putOperation.generate(generator);
57 final var patchOperation = patch();
58 if (patchOperation != null) {
59 patchOperation.generate(generator);
61 final var deleteOperation = delete();
62 if (deleteOperation != null) {
63 deleteOperation.generate(generator);
65 final var getOperation = get();
66 if (getOperation != null) {
67 getOperation.generate(generator);
69 generator.writeEndObject();
72 @Nullable String ref() {
76 @Nullable String summary() {
80 @Nullable String description() {
84 @Nullable OperationEntity post() {
88 @Nullable OperationEntity put() {
92 @Nullable OperationEntity patch() {
96 @Nullable OperationEntity get() {
100 @Nullable OperationEntity delete() {