From dcae08a2a058d8165d9fe229c04c22a3b46dd9d9 Mon Sep 17 00:00:00 2001 From: winrid Date: Sun, 15 Nov 2026 21:12:58 -0800 Subject: [PATCH 1/2] pubsub: reconnect after failed connects and drops, with backoff - onFailure (a failed connect, or a dropped socket from a server restart or network change) now reconnects; before, only onClosed did, so one failure ended live updates for good. - The reconnect reuses urlIdWS, so it rejoins the same room instead of the raw urlId. - Backoff is full jitter over a 4s window doubling to 60s, reset on open; a 4xx upgrade is retried every 5 minutes. - One idle-timeout scheduler thread per subscriber instead of a Timer thread per reconnect. - close() reaches the current socket after reconnects; only the newest connection may reconnect, and onClosing/onClosed schedule one reconnect between them (compareAndSet), so no stray socket delivers events twice. - lastEventTime is an AtomicLong, so concurrent event times can't move it backwards. --- pubsub/build.gradle | 3 + .../pubsub/LiveEventSubscriber.java | 237 +++++++++----- .../LiveEventSubscriberReconnectTest.java | 309 ++++++++++++++++++ 3 files changed, 463 insertions(+), 86 deletions(-) create mode 100644 pubsub/src/test/java/com/fastcomments/pubsub/LiveEventSubscriberReconnectTest.java diff --git a/pubsub/build.gradle b/pubsub/build.gradle index 493d0e80..eb9947c8 100644 --- a/pubsub/build.gradle +++ b/pubsub/build.gradle @@ -74,6 +74,9 @@ dependencies { // This works better for local publishing when run from the pubsub directory implementation "com.fastcomments:client:${version}" implementation "com.fastcomments:core:${version}" + + testImplementation 'junit:junit:4.13.2' + testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0' } javadoc { diff --git a/pubsub/src/main/java/com/fastcomments/pubsub/LiveEventSubscriber.java b/pubsub/src/main/java/com/fastcomments/pubsub/LiveEventSubscriber.java index 12e4f5cc..efe365e1 100644 --- a/pubsub/src/main/java/com/fastcomments/pubsub/LiveEventSubscriber.java +++ b/pubsub/src/main/java/com/fastcomments/pubsub/LiveEventSubscriber.java @@ -13,15 +13,24 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; +import java.util.function.DoubleSupplier; /** * Main class for subscribing to FastComments live changes */ public class LiveEventSubscriber { - private static final long RECONNECT_INTERVAL_BASE = 4000; // 4 seconds + private static final long RECONNECT_DELAY_INITIAL_MS = 4000; + private static final long RECONNECT_DELAY_MAX_MS = 60000; + // A rejected upgrade (4xx: auth, rate limit, bad params) won't clear up in seconds, so it's retried rarely instead. + private static final long REJECTED_RECONNECT_DELAY_MS = 5 * 60 * 1000; private static final long DEFAULT_PING_INTERVAL_SECONDS = 25; private static final long TESTING_PING_INTERVAL_SECONDS = 5; @@ -36,6 +45,11 @@ public class LiveEventSubscriber { .dispatcher(new Dispatcher()) .build(); private final OkHttpClient client; + // Tests point this at a local server; null means the region's real host. + private final String wsHostOverride; + private final ScheduledThreadPoolExecutor reconnectScheduler = newReconnectScheduler(); + // Tests pin this to make reconnect timing deterministic. + private final DoubleSupplier jitter; private final Map debouncers = new ConcurrentHashMap<>(); private ConnectionStatusChangeCallback onConnectionStatusChange; @@ -50,12 +64,52 @@ private static OkHttpClient buildClient(long pingIntervalSeconds) { .build(); } + // One thread per subscriber that exits when idle, instead of a Timer thread per reconnect left waiting for GC. + private static ScheduledThreadPoolExecutor newReconnectScheduler() { + ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(1, runnable -> { + Thread thread = new Thread(runnable, "fastcomments-ws-reconnect"); + thread.setDaemon(true); + return thread; + }); + scheduler.setKeepAliveTime(30, TimeUnit.SECONDS); + scheduler.allowCoreThreadTimeOut(true); + scheduler.setRemoveOnCancelPolicy(true); + return scheduler; + } + + /** + * Delay before reconnect attempt number {@code attempt} (0-based): full jitter over a window that starts at 4s and + * doubles to a 60s cap. A server restart drops every client at once, so the first retry (and the event-log fetch + * each reconnect makes) has to spread over seconds, not land in one burst. + */ + static long reconnectDelayMs(int attempt, double random) { + long window = Math.min(RECONNECT_DELAY_MAX_MS, RECONNECT_DELAY_INITIAL_MS << Math.min(attempt, 4)); + return (long) (window * random); + } + + /** + * State shared by every socket one subscribeToChanges call opens, since reconnects replace the socket. + */ + private static final class SubscriptionState { + final AtomicBoolean closed = new AtomicBoolean(); + final AtomicReference socket = new AtomicReference<>(); + // Only the newest connection may reconnect, so a late failure from a replaced socket can't open a second one. + final AtomicInteger generation = new AtomicInteger(); + final AtomicInteger failedAttempts = new AtomicInteger(); + } + public LiveEventSubscriber() { - this.client = buildClient(DEFAULT_PING_INTERVAL_SECONDS); + this(DEFAULT_PING_INTERVAL_SECONDS, null); + } + + LiveEventSubscriber(long pingIntervalSeconds, String wsHostOverride) { + this(pingIntervalSeconds, wsHostOverride, Math::random); } - private LiveEventSubscriber(long pingIntervalSeconds) { + LiveEventSubscriber(long pingIntervalSeconds, String wsHostOverride, DoubleSupplier jitter) { this.client = buildClient(pingIntervalSeconds); + this.wsHostOverride = wsHostOverride; + this.jitter = jitter; } /** @@ -63,9 +117,19 @@ private LiveEventSubscriber(long pingIntervalSeconds) { * useful for Android NAT environments where connections drop more aggressively. */ public static LiveEventSubscriber createTesting() { - return new LiveEventSubscriber(TESTING_PING_INTERVAL_SECONDS); + return new LiveEventSubscriber(TESTING_PING_INTERVAL_SECONDS, null); + } + // Written from socket reader threads and the event-log fetch's callback thread; a lost max() update moves it + // backwards, and the next reconnect then refetches events already delivered. + private final AtomicLong lastEventTime = new AtomicLong(); + + void recordEventTime(long timestamp) { + lastEventTime.accumulateAndGet(timestamp, Math::max); + } + + long getLastEventTime() { + return lastEventTime.get(); } - private long lastEventTime; /** * Interface for a callback that checks if comments can be seen before handling a live event. @@ -121,7 +185,7 @@ private void processEvents( try { // Update the last live event time if (eventData.getTimestamp() != null) { - lastEventTime = Math.max(lastEventTime, eventData.getTimestamp()); + recordEventTime(eventData.getTimestamp()); } // Extract comment ID for blocking check @@ -168,53 +232,62 @@ private void processEvents( private class FastCommentsWebSocketListener extends WebSocketListener { private final HandleLiveEventCallback handleLiveEvent; private final CanSeeCommentsCallback canSeeCommentsCallback; - private final boolean[] isIntentionallyClosed; + private final SubscriptionState state; + private final int generation; private final CommentWidgetConfig config; - private Timer reconnectTimer; + // onClosing and onClosed both fire for one close, on different OkHttp threads, so this must be atomic: two + // reconnects would leave a socket open that close() never reaches, delivering every event twice. + private final AtomicBoolean reconnectScheduled = new AtomicBoolean(); private final String tenantId; private final String urlId; + private final String urlIdWS; private final String userIdWS; public FastCommentsWebSocketListener( HandleLiveEventCallback handleLiveEvent, CanSeeCommentsCallback canSeeCommentsCallback, - boolean[] isIntentionallyClosed, + SubscriptionState state, CommentWidgetConfig config, String tenantId, String urlId, + String urlIdWS, String userIdWS ) { this.handleLiveEvent = handleLiveEvent; this.canSeeCommentsCallback = canSeeCommentsCallback; - this.isIntentionallyClosed = isIntentionallyClosed; + this.state = state; + this.generation = state.generation.get(); this.config = config; this.tenantId = tenantId; this.urlId = urlId; + this.urlIdWS = urlIdWS; this.userIdWS = userIdWS; } @Override public void onOpen(WebSocket webSocket, Response response) { - if (isIntentionallyClosed[0]) { + if (state.closed.get()) { webSocket.close(1000, "Intentionally closed"); return; } + state.failedAttempts.set(0); // Fetch missed events if we have a last event time - if (lastEventTime > 0) { - fetchEventLog(config.region, tenantId, urlId, userIdWS, lastEventTime, new Date().getTime(), + long since = lastEventTime.get(); + if (since > 0) { + fetchEventLog(config.region, tenantId, urlId, userIdWS, since, new Date().getTime(), events -> processEvents(events, canSeeCommentsCallback, handleLiveEvent)); } // Call connection status change callback if (onConnectionStatusChange != null) { - onConnectionStatusChange.onChange(true, lastEventTime); + onConnectionStatusChange.onChange(true, since); } } @Override public void onMessage(WebSocket webSocket, String text) { - if (isIntentionallyClosed[0]) { + if (state.closed.get()) { return; } @@ -224,7 +297,7 @@ public void onMessage(WebSocket webSocket, String text) { // Update last event time if (eventDataParsed.getTimestamp() != null) { - lastEventTime = Math.max(lastEventTime, eventDataParsed.getTimestamp()); + recordEventTime(eventDataParsed.getTimestamp()); } else { // otherwise getTs() might not be null, but those are for presence updates only, and those are not stored in the log so we don't // want to track them @@ -251,31 +324,24 @@ public void onFailure(WebSocket webSocket, Throwable t, Response response) { } t.printStackTrace(); - // Fetch missed events if we have a last event time - if (lastEventTime > 0) { - fetchEventLog(config.region, tenantId, urlId, userIdWS, lastEventTime, new Date().getTime(), - events -> processEvents(events, canSeeCommentsCallback, handleLiveEvent)); - } + // A failed connect or a dropped socket (a server restart, a network change) ends here, not in onClosed, + // so this has to reconnect too. The reconnect's onOpen fetches the events missed meanwhile. + boolean rejected = response != null && response.code() >= 400 && response.code() < 500; + cleanup(rejected); } @Override public void onClosing(WebSocket webSocket, int code, String reason) { webSocket.close(1000, "Client closing"); - cleanup(); + cleanup(false); } @Override public void onClosed(WebSocket webSocket, int code, String reason) { - cleanup(); + cleanup(false); } - private void cleanup() { - // Cancel any existing reconnect timer - if (reconnectTimer != null) { - reconnectTimer.cancel(); - reconnectTimer = null; - } - + private void cleanup(boolean rejected) { // Clean up all debouncer timers for (Timer timer : debouncers.values()) { timer.cancel(); @@ -283,38 +349,25 @@ private void cleanup() { debouncers.clear(); // Initialize last event time if not set - if (lastEventTime <= 0) { - lastEventTime = new Date().getTime(); - } + lastEventTime.compareAndSet(0, new Date().getTime()); // Call connection status change callback - if (!isIntentionallyClosed[0]) { + if (!state.closed.get() && state.generation.get() == generation + && reconnectScheduled.compareAndSet(false, true)) { if (onConnectionStatusChange != null) { - onConnectionStatusChange.onChange(false, lastEventTime); + onConnectionStatusChange.onChange(false, lastEventTime.get()); } - // Schedule reconnection with jitter - double jitter = Math.random(); - long reconnectDelay = (long) (RECONNECT_INTERVAL_BASE * jitter); - - reconnectTimer = new Timer(); - reconnectTimer.schedule(new TimerTask() { - @Override - public void run() { - if (!isIntentionallyClosed[0]) { - // Reconnect using the subscribeToChanges method to handle the full setup - subscribeToChanges( - config, - tenantId, - urlId, - urlId, // We'll use urlId for urlIdWS too since it's already normalized - userIdWS, - canSeeCommentsCallback, - handleLiveEvent - ); - } + long delay = rejected + ? REJECTED_RECONNECT_DELAY_MS + : reconnectDelayMs(state.failedAttempts.getAndIncrement(), jitter.getAsDouble()); + reconnectScheduler.schedule(() -> { + if (!state.closed.get()) { + // Same subscription state, so the caller's close() reaches the new socket + connect(config, tenantId, urlId, urlIdWS, userIdWS, canSeeCommentsCallback, handleLiveEvent, + state); } - }, reconnectDelay); + }, delay, TimeUnit.MILLISECONDS); } } } @@ -432,41 +485,20 @@ public SubscribeToChangesResult subscribeToChanges( return null; } - final boolean[] isIntentionallyClosed = {false}; - lastEventTime = lastEventTime != 0 ? lastEventTime : new Date().getTime(); - - // Check if we should use polling instead of WebSocket + final SubscriptionState state = new SubscriptionState(); + lastEventTime.compareAndSet(0, new Date().getTime()); - // Use WebSocket for live updates try { - // Build the WebSocket URL with query parameters - final String WS_HOST = Objects.equals(config.region, "eu") ? "wss://ws-eu.fastcomments.com" : "wss://ws.fastcomments.com"; - String wsUrl = WS_HOST + "/sub" + "?urlId=" + urlIdWS + - "&userIdWS=" + userIdWS + - "&tenantIdWS=" + tenantIdWS; - // Create WebSocket listener - FastCommentsWebSocketListener listener = new FastCommentsWebSocketListener( - handleLiveEvent, - canSeeCommentsCallback, - isIntentionallyClosed, - config, - tenantIdWS, - urlId, - userIdWS - ); - - // Create request for WebSocket connection - Request request = new Request.Builder() - .url(wsUrl) - .build(); - - // Connect to WebSocket - final WebSocket webSocket = client.newWebSocket(request, listener); + connect(config, tenantIdWS, urlId, urlIdWS, userIdWS, canSeeCommentsCallback, handleLiveEvent, state); // Return result with close handler return new SubscribeToChangesResult(() -> { - isIntentionallyClosed[0] = true; - webSocket.close(1000, "Closed by user"); + state.closed.set(true); + // Reconnects replace the socket, so this closes whichever one is current. + WebSocket webSocket = state.socket.get(); + if (webSocket != null) { + webSocket.close(1000, "Closed by user"); + } }); } catch (Exception e) { System.err.println("FastComments: Error setting up WebSocket: " + e.getMessage()); @@ -478,4 +510,37 @@ public SubscribeToChangesResult subscribeToChanges( } } + private void connect( + CommentWidgetConfig config, + String tenantIdWS, + String urlId, + String urlIdWS, + String userIdWS, + CanSeeCommentsCallback canSeeCommentsCallback, + HandleLiveEventCallback handleLiveEvent, + SubscriptionState state + ) { + state.generation.incrementAndGet(); + // Build the WebSocket URL with query parameters + final String WS_HOST = wsHostOverride != null ? wsHostOverride + : Objects.equals(config.region, "eu") ? "wss://ws-eu.fastcomments.com" : "wss://ws.fastcomments.com"; + String wsUrl = WS_HOST + "/sub" + "?urlId=" + urlIdWS + + "&userIdWS=" + userIdWS + + "&tenantIdWS=" + tenantIdWS; + FastCommentsWebSocketListener listener = new FastCommentsWebSocketListener( + handleLiveEvent, + canSeeCommentsCallback, + state, + config, + tenantIdWS, + urlId, + urlIdWS, + userIdWS + ); + Request request = new Request.Builder() + .url(wsUrl) + .build(); + state.socket.set(client.newWebSocket(request, listener)); + } + } \ No newline at end of file diff --git a/pubsub/src/test/java/com/fastcomments/pubsub/LiveEventSubscriberReconnectTest.java b/pubsub/src/test/java/com/fastcomments/pubsub/LiveEventSubscriberReconnectTest.java new file mode 100644 index 00000000..6d6e4d9c --- /dev/null +++ b/pubsub/src/test/java/com/fastcomments/pubsub/LiveEventSubscriberReconnectTest.java @@ -0,0 +1,309 @@ +package com.fastcomments.pubsub; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import com.fastcomments.core.CommentWidgetConfig; +import com.fastcomments.model.LiveEvent; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import okhttp3.Response; +import okhttp3.WebSocket; +import okhttp3.WebSocketListener; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import okhttp3.mockwebserver.SocketPolicy; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class LiveEventSubscriberReconnectTest { + + private MockWebServer server; + private SubscribeToChangesResult subscription; + + @Before + public void setUp() throws Exception { + server = new MockWebServer(); + server.start(); + } + + @After + public void tearDown() throws Exception { + if (subscription != null) { + subscription.close(); + } + server.shutdown(); + } + + private String wsHost() { + String url = server.url("/").toString().replaceFirst("^http", "ws"); + return url.substring(0, url.length() - 1); + } + + private MockResponse acceptAndSend(String message) { + return new MockResponse() + .withWebSocketUpgrade( + new WebSocketListener() { + @Override + public void onOpen(WebSocket webSocket, Response response) { + webSocket.send(message); + } + + @Override + public void onClosing(WebSocket webSocket, int code, String reason) { + webSocket.close(1000, null); + } + }); + } + + @Test + public void reconnectsToTheSameRoomAfterAFailedConnect() throws Exception { + // The server dropping the upgrade is what a device saw: "unexpected end of stream", then no live updates. + server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.DISCONNECT_AT_START)); + server.enqueue( + acceptAndSend( + "{\"type\":\"poll-update\",\"timestamp\":1,\"commentId\":\"c1\"}")); + + LiveEventSubscriber subscriber = + new LiveEventSubscriber(5, wsHost()); + CountDownLatch received = new CountDownLatch(1); + AtomicReference event = new AtomicReference<>(); + subscription = + subscriber.subscribeToChanges( + new CommentWidgetConfig("tenant1", "page"), + "tenant1", + "page", + "tenant1:page", + "user-ws", + null, + liveEvent -> { + event.set(liveEvent); + received.countDown(); + }); + + assertNotNull(server.takeRequest(10, TimeUnit.SECONDS)); + RecordedRequest second = server.takeRequest(10, TimeUnit.SECONDS); + assertNotNull("never reconnected after the failed connect", second); + // A failed connect and a dropped open socket (a server restart) both land in onFailure. + assertEquals("/sub?urlId=tenant1:page&userIdWS=user-ws&tenantIdWS=tenant1", second.getPath()); + assertEquals(true, received.await(10, TimeUnit.SECONDS)); + assertEquals("c1", event.get().getCommentId()); + } + + private SubscribeToChangesResult subscribe() { + return new LiveEventSubscriber(5, wsHost()) + .subscribeToChanges( + new CommentWidgetConfig("tenant1", "page"), + "tenant1", + "page", + "tenant1:page", + "user-ws", + null, + liveEvent -> {}); + } + + @Test + public void reconnectDelayIsFullJitterOverADoublingWindowUpToAMinute() { + // The first retry after a mass disconnect is spread over 4s, so a server restart doesn't bring every + // client (and its event-log fetch) back in the same instant. + assertEquals(0, LiveEventSubscriber.reconnectDelayMs(0, 0)); + assertEquals(4000, LiveEventSubscriber.reconnectDelayMs(0, 1)); + assertEquals(2000, LiveEventSubscriber.reconnectDelayMs(0, 0.5)); + assertEquals(8000, LiveEventSubscriber.reconnectDelayMs(1, 1)); + assertEquals(16000, LiveEventSubscriber.reconnectDelayMs(2, 1)); + assertEquals(32000, LiveEventSubscriber.reconnectDelayMs(3, 1)); + assertEquals(60000, LiveEventSubscriber.reconnectDelayMs(4, 1)); + // Long outages stay at the cap instead of overflowing the shift. + assertEquals(60000, LiveEventSubscriber.reconnectDelayMs(1000, 1)); + } + + @Test + public void backsOffBetweenFailedReconnectsAndResetsOnceConnected() throws Exception { + server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.DISCONNECT_AT_START)); + server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.DISCONNECT_AT_START)); + server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.DISCONNECT_AT_START)); + // Opens, then the server closes it, so the next reconnect starts from the first step again. + server.enqueue( + new MockResponse() + .withWebSocketUpgrade( + new WebSocketListener() { + @Override + public void onOpen(WebSocket webSocket, Response response) { + webSocket.close(1001, "restarting"); + } + })); + server.enqueue(acceptAndSend("{\"type\":\"poll-update\",\"timestamp\":4,\"commentId\":\"c4\"}")); + + // Jitter pinned to a quarter of each window: 1s, 2s, 4s, then 1s again once a connection opens. + subscription = + new LiveEventSubscriber(5, wsHost(), () -> 0.25) + .subscribeToChanges( + new CommentWidgetConfig("tenant1", "page"), + "tenant1", + "page", + "tenant1:page", + "user-ws", + null, + liveEvent -> {}); + long[] arrivals = new long[5]; + for (int i = 0; i < arrivals.length; i++) { + assertNotNull("attempt " + i + " never came", server.takeRequest(20, TimeUnit.SECONDS)); + arrivals[i] = System.nanoTime(); + } + long[] expected = {1000, 2000, 4000, 1000}; + StringBuilder gaps = new StringBuilder(); + for (int i = 0; i < expected.length; i++) { + gaps.append(TimeUnit.NANOSECONDS.toMillis(arrivals[i + 1] - arrivals[i])).append("ms "); + } + for (int i = 0; i < expected.length; i++) { + long gap = TimeUnit.NANOSECONDS.toMillis(arrivals[i + 1] - arrivals[i]); + assertTrue("gap " + i + " should be ~" + expected[i] + "ms: " + gaps, + gap >= expected[i] - 100 && gap <= expected[i] + 700); + } + } + + @Test + public void lastEventTimeNeverMovesBackwardsUnderConcurrentEvents() throws Exception { + // Socket reader threads and the event-log fetch both record times. A lost update moves it backwards, and the + // next reconnect then refetches (and redelivers) events the app already has. + LiveEventSubscriber subscriber = new LiveEventSubscriber(5, wsHost()); + int writers = 4; + long perWriter = 2_000_000; + AtomicBoolean done = new AtomicBoolean(); + AtomicReference regression = new AtomicReference<>(); + Thread watcher = new Thread(() -> { + long seen = 0; + while (!done.get() && regression.get() == null) { + long now = subscriber.getLastEventTime(); + if (now < seen) { + regression.set(seen + " -> " + now); + } + seen = now; + } + }); + watcher.start(); + Thread[] threads = new Thread[writers]; + for (int w = 0; w < writers; w++) { + final int offset = w; + threads[w] = new Thread(() -> { + for (long i = 1; i <= perWriter; i++) { + subscriber.recordEventTime(i * writers + offset); + } + }); + threads[w].start(); + } + for (Thread thread : threads) { + thread.join(); + } + done.set(true); + watcher.join(); + assertNull("lastEventTime moved backwards: " + regression.get(), regression.get()); + assertEquals(perWriter * writers + writers - 1, subscriber.getLastEventTime()); + } + + @Test + public void aServerCloseSchedulesOneReconnect() throws Exception { + // The server closes, so onClosing replies with close() and OkHttp's writer thread runs onClosed while + // onClosing is still in cleanup. Two reconnects would leave a second socket open that close() never reaches. + server.enqueue( + new MockResponse() + .withWebSocketUpgrade( + new WebSocketListener() { + @Override + public void onOpen(WebSocket webSocket, Response response) { + webSocket.close(1001, "restarting"); + } + })); + server.enqueue(acceptAndSend("{\"type\":\"poll-update\",\"timestamp\":6,\"commentId\":\"c6\"}")); + server.enqueue(acceptAndSend("{\"type\":\"poll-update\",\"timestamp\":7,\"commentId\":\"c7\"}")); + + LiveEventSubscriber subscriber = new LiveEventSubscriber(5, wsHost(), () -> 0); + AtomicInteger disconnects = new AtomicInteger(); + // A slow status callback holds cleanup open long enough for both close callbacks to be inside it. + subscriber.setOnConnectionStatusChange((isConnected, lastLiveEventTime) -> { + if (!isConnected) { + disconnects.incrementAndGet(); + try { + Thread.sleep(300); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + }); + subscription = + subscriber.subscribeToChanges( + new CommentWidgetConfig("tenant1", "page"), + "tenant1", + "page", + "tenant1:page", + "user-ws", + null, + liveEvent -> {}); + + assertNotNull(server.takeRequest(10, TimeUnit.SECONDS)); + assertNotNull("never reconnected after the server closed", server.takeRequest(10, TimeUnit.SECONDS)); + assertNull("one close opened two reconnects", server.takeRequest(2, TimeUnit.SECONDS)); + assertEquals(1, disconnects.get()); + } + + @Test + public void aRejectedUpgradeIsNotRetriedRightAway() throws Exception { + server.enqueue(new MockResponse().setResponseCode(403)); + server.enqueue(acceptAndSend("{\"type\":\"poll-update\",\"timestamp\":5,\"commentId\":\"c5\"}")); + + subscription = subscribe(); + assertNotNull(server.takeRequest(10, TimeUnit.SECONDS)); + // A 4xx won't fix itself within seconds, so retrying on the normal schedule would only hammer the server. + assertNull("retried a 403 right away", server.takeRequest(6, TimeUnit.SECONDS)); + } + + @Test + public void closeAfterAReconnectClosesTheNewSocket() throws Exception { + server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.DISCONNECT_AT_START)); + CountDownLatch serverSawClose = new CountDownLatch(1); + server.enqueue( + new MockResponse() + .withWebSocketUpgrade( + new WebSocketListener() { + @Override + public void onOpen(WebSocket webSocket, Response response) { + webSocket.send( + "{\"type\":\"poll-update\",\"timestamp\":3,\"commentId\":\"c3\"}"); + } + + @Override + public void onClosing(WebSocket webSocket, int code, String reason) { + serverSawClose.countDown(); + webSocket.close(1000, null); + } + })); + + LiveEventSubscriber subscriber = + new LiveEventSubscriber(5, wsHost()); + CountDownLatch received = new CountDownLatch(1); + subscription = + subscriber.subscribeToChanges( + new CommentWidgetConfig("tenant1", "page"), + "tenant1", + "page", + "tenant1:page", + "user-ws", + null, + liveEvent -> received.countDown()); + assertEquals(true, received.await(15, TimeUnit.SECONDS)); + + subscription.close(); + subscription = null; + assertEquals("close() left the reconnected socket open", true, serverSawClose.await(5, TimeUnit.SECONDS)); + server.takeRequest(1, TimeUnit.SECONDS); + server.takeRequest(1, TimeUnit.SECONDS); + assertNull("reconnected again after close()", server.takeRequest(6, TimeUnit.SECONDS)); + } +} From 4f27781ef023928ed4af29fad2611a981e77e34c Mon Sep 17 00:00:00 2001 From: winrid Date: Sun, 15 Nov 2026 22:10:25 -0800 Subject: [PATCH 2/2] Release v3.1.2: ignore unknown response fields, pubsub reconnect fixes The spec no longer marks models additionalProperties: false, so the regenerated models keep fields they don't know instead of throwing. getCommentsPublic threw on the new allowSimpleSSOAdmins customConfig field for Simple SSO tenants. New fields: CustomConfigParameters.allowSimpleSSOAdmins and autoVerifySimpleSSOComments, TenantPackage.pricingCurrency, monthlyCostLocal and yearlyCostLocal, WebhookComment.badges. --- README.md | 12 +- client/README.md | 6 +- client/api/openapi.yaml | 770 +++++++----------- client/build.gradle | 2 +- client/build.sbt | 2 +- client/docs/CustomConfigParameters.md | 2 + client/docs/TenantPackage.md | 5 +- client/docs/WebhookComment.md | 1 + client/pom.xml | 2 +- .../com/fastcomments/invoker/ApiClient.java | 2 +- .../fastcomments/invoker/Configuration.java | 2 +- .../com/fastcomments/model/APIAuditLog.java | 103 ++- .../model/APIBanUserChangeLog.java | 103 ++- .../model/APIBanUserChangedValues.java | 103 ++- .../com/fastcomments/model/APIBannedUser.java | 103 ++- .../fastcomments/model/APICommentBase.java | 103 ++- .../model/APICommentCommonBannedUser.java | 103 ++- .../model/APICreateUserBadgeResponse.java | 103 ++- .../model/APIDomainConfiguration.java | 103 ++- .../model/APIEmptySuccessResponse.java | 103 ++- .../java/com/fastcomments/model/APIError.java | 103 ++- .../model/APIGetCommentResponse.java | 103 ++- .../model/APIGetCommentsResponse.java | 103 ++- .../APIGetUserBadgeProgressListResponse.java | 103 ++- .../APIGetUserBadgeProgressResponse.java | 103 ++- .../model/APIGetUserBadgeResponse.java | 103 ++- .../model/APIGetUserBadgesResponse.java | 103 ++- .../model/APIModerateUserBanPreferences.java | 103 ++- .../com/fastcomments/model/APISSOUser.java | 103 ++- .../model/APISaveCommentResponse.java | 103 ++- .../com/fastcomments/model/APITenant.java | 103 ++- .../model/APITenantDailyUsage.java | 103 ++- .../com/fastcomments/model/APITicket.java | 103 ++- .../fastcomments/model/APITicketDetail.java | 103 ++- .../com/fastcomments/model/APITicketFile.java | 103 ++- .../model/AddDomainConfigParams.java | 103 ++- .../model/AdjustCommentVotesParams.java | 103 ++- .../model/AdjustVotesResponse.java | 103 ++- .../AggregateQuestionResultsResponse.java | 103 ++- .../model/AggregationAPIError.java | 103 ++- .../model/AggregationOperation.java | 103 ++- .../model/AggregationRequest.java | 103 ++- .../model/AggregationResponse.java | 103 ++- .../model/BanUserFromCommentResult.java | 103 ++- .../fastcomments/model/BanUserUndoParams.java | 103 ++- .../fastcomments/model/BannedUserMatch.java | 103 ++- .../com/fastcomments/model/BillingInfo.java | 103 ++- .../model/BlockFromCommentParams.java | 103 ++- .../com/fastcomments/model/BlockSuccess.java | 103 ++- .../model/BuildModerationFilterResponse.java | 103 ++- .../model/BulkAggregateQuestionItem.java | 103 ++- .../BulkAggregateQuestionResultsRequest.java | 103 ++- .../BulkAggregateQuestionResultsResponse.java | 103 ++- .../model/BulkCreateHashTagsBody.java | 103 ++- .../model/BulkCreateHashTagsResponse.java | 103 ++- .../fastcomments/model/BulkPreBanParams.java | 103 ++- .../fastcomments/model/BulkPreBanSummary.java | 103 ++- .../model/ChangeTicketStateBody.java | 103 ++- .../model/ChangeTicketStateResponse.java | 103 ++- ...neQuestionResultsWithCommentsResponse.java | 103 ++- .../com/fastcomments/model/CommentData.java | 103 ++- .../fastcomments/model/CommentLogData.java | 103 ++- .../fastcomments/model/CommentLogEntry.java | 103 ++- .../com/fastcomments/model/CommentPoll.java | 103 ++- .../fastcomments/model/CommentPollInput.java | 103 ++- .../fastcomments/model/CommentPollOption.java | 103 ++- .../model/CommentPollOptionInput.java | 103 ++- .../fastcomments/model/CommentPollPatch.java | 103 ++- .../model/CommentPollPutInput.java | 103 ++- .../model/CommentTextUpdateRequest.java | 103 ++- .../model/CommentTranslation.java | 103 ++- .../model/CommentTranslationPublic.java | 103 ++- .../model/CommentTranslationsRequest.java | 103 ++- .../model/CommentTranslationsResponse.java | 103 ++- .../model/CommentUserBadgeInfo.java | 103 ++- .../model/CommentUserHashTagInfo.java | 103 ++- .../model/CommentUserMentionInfo.java | 103 ++- .../model/CommentsByIdsParams.java | 103 ++- .../model/CreateAgentTenantBody.java | 103 ++- .../model/CreateAgentTenantResponse.java | 103 ++- .../model/CreateCommentParams.java | 103 ++- .../model/CreateEmailTemplateBody.java | 103 ++- .../model/CreateEmailTemplateResponse.java | 103 ++- .../model/CreateFeedPostParams.java | 103 ++- .../model/CreateFeedPostResponse.java | 103 ++- .../model/CreateFeedPostsResponse.java | 103 ++- .../fastcomments/model/CreateHashTagBody.java | 103 ++- .../model/CreateHashTagResponse.java | 103 ++- .../model/CreateModeratorResponse.java | 103 ++- .../model/CreatePollVoteBody.java | 103 ++- .../model/CreatePollVoteResponse.java | 103 ++- .../model/CreateQuestionConfigResponse.java | 103 ++- .../model/CreateQuestionResultResponse.java | 103 ++- .../fastcomments/model/CreateTenantBody.java | 103 ++- .../model/CreateTenantPackageBody.java | 103 ++- .../model/CreateTenantPackageResponse.java | 103 ++- .../model/CreateTenantResponse.java | 103 ++- .../model/CreateTenantUserBody.java | 103 ++- .../model/CreateTenantUserResponse.java | 103 ++- .../fastcomments/model/CreateTicketBody.java | 103 ++- .../model/CreateTicketResponse.java | 103 ++- .../model/CreateUserBadgeParams.java | 103 ++- .../model/CreateWebhookParams.java | 103 ++- .../model/CreateWebhookResponse.java | 103 ++- .../model/CustomConfigParameters.java | 157 +++- .../model/CustomEmailTemplate.java | 103 ++- .../model/DeletePollVoteResponse.java | 103 ++- .../model/DeletedCommentResultComment.java | 103 ++- .../model/EmailTemplateDefinition.java | 103 ++- .../EmailTemplateRenderErrorResponse.java | 103 ++- .../com/fastcomments/model/EventLogEntry.java | 103 ++- .../java/com/fastcomments/model/FComment.java | 103 ++- .../java/com/fastcomments/model/FeedPost.java | 103 ++- .../com/fastcomments/model/FeedPostLink.java | 103 ++- .../fastcomments/model/FeedPostMediaItem.java | 103 ++- .../model/FeedPostMediaItemAsset.java | 103 ++- .../com/fastcomments/model/FeedPostStats.java | 103 ++- .../model/FeedPostsStatsResponse.java | 103 ++- .../model/FindCommentsByRangeItem.java | 103 ++- .../model/FindCommentsByRangeResponse.java | 103 ++- .../model/FlagCommentResponse.java | 103 ++- .../model/GetAuditLogsResponse.java | 103 ++- .../GetCachedNotificationCountResponse.java | 103 ++- .../model/GetCommentBanStatusResponse.java | 103 ++- ...etCommentVoteUserNamesSuccessResponse.java | 103 ++- .../GetCommentsResponsePublicComment.java | 103 ++- .../GetEmailTemplateDefinitionsResponse.java | 103 ++- .../GetEmailTemplateRenderErrorsResponse.java | 103 ++- .../model/GetEmailTemplateResponse.java | 103 ++- .../model/GetEmailTemplatesResponse.java | 103 ++- .../model/GetFeedPostsResponse.java | 103 ++- .../model/GetHashTagsResponse.java | 103 ++- .../com/fastcomments/model/GetMeResponse.java | 103 ++- .../model/GetModeratorResponse.java | 103 ++- .../model/GetModeratorsResponse.java | 103 ++- .../model/GetNotificationCountResponse.java | 103 ++- .../model/GetNotificationsResponse.java | 103 ++- .../GetPendingWebhookEventCountResponse.java | 103 ++- .../GetPendingWebhookEventsResponse.java | 103 ++- .../fastcomments/model/GetPollResponse.java | 103 ++- .../model/GetPollVoteResponse.java | 103 ++- .../GetPollVoterNamesSuccessResponse.java | 103 ++- .../model/GetPollVotesResponse.java | 103 ++- .../model/GetPublicFeedPostsResponse.java | 103 ++- .../model/GetQuestionConfigResponse.java | 103 ++- .../model/GetQuestionConfigsResponse.java | 103 ++- .../model/GetQuestionResultResponse.java | 103 ++- .../model/GetQuestionResultsResponse.java | 103 ++- .../model/GetTenantDailyUsagesResponse.java | 103 ++- .../model/GetTenantPackageResponse.java | 103 ++- .../model/GetTenantPackagesResponse.java | 103 ++- .../fastcomments/model/GetTenantResponse.java | 103 ++- .../model/GetTenantUserResponse.java | 103 ++- .../model/GetTenantUsersResponse.java | 103 ++- .../model/GetTenantsResponse.java | 103 ++- .../fastcomments/model/GetTicketResponse.java | 103 ++- .../model/GetTicketsResponse.java | 103 ++- .../GetUserNotificationCountResponse.java | 103 ++- .../fastcomments/model/GetUserResponse.java | 103 ++- .../model/GetVotesForUserResponse.java | 103 ++- .../fastcomments/model/GetVotesResponse.java | 103 ++- .../GetWebhookSamplePayloadsResponse.java | 103 ++- .../model/GetWebhooksResponse.java | 103 ++- .../model/HeaderAccountNotification.java | 103 ++- .../com/fastcomments/model/HeaderState.java | 103 ++- .../fastcomments/model/IgnoredResponse.java | 103 ++- .../com/fastcomments/model/LiveEvent.java | 103 ++- .../com/fastcomments/model/MediaAsset.java | 103 ++- .../java/com/fastcomments/model/MetaItem.java | 103 ++- .../model/ModerationAPIComment.java | 103 ++- .../model/ModerationAPICommentLog.java | 103 ++- .../ModerationAPICountCommentsResponse.java | 103 ++- .../ModerationAPIGetCommentsResponse.java | 103 ++- .../model/ModerationExportResponse.java | 103 ++- .../model/ModerationExportStatusResponse.java | 103 ++- .../fastcomments/model/ModerationFilter.java | 103 ++- .../model/ModerationPageSearchProjected.java | 103 ++- .../model/ModerationSiteSearchProjected.java | 103 ++- .../model/ModerationSuggestResponse.java | 103 ++- .../model/ModerationUserSearchProjected.java | 103 ++- .../com/fastcomments/model/Moderator.java | 103 ++- .../model/NotificationAndCount.java | 103 ++- .../com/fastcomments/model/PageMigration.java | 103 ++- .../model/PageMigrationFailure.java | 103 ++- .../model/PageMigrationSuccess.java | 103 ++- .../model/PageMigrationUndoCounts.java | 103 ++- .../model/PatchDomainConfigParams.java | 103 ++- .../model/PendingCommentToSyncOutbound.java | 103 ++- .../fastcomments/model/PollVoterEntry.java | 103 ++- .../com/fastcomments/model/PreBanSummary.java | 103 ++- .../fastcomments/model/PubSubCommentBase.java | 103 ++- .../com/fastcomments/model/PubSubVote.java | 103 ++- .../model/PublicBlockFromCommentParams.java | 103 ++- .../fastcomments/model/PublicCommentBase.java | 103 ++- .../fastcomments/model/PublicPollVote.java | 103 ++- .../com/fastcomments/model/PublicVote.java | 103 ++- .../com/fastcomments/model/PublicWebhook.java | 103 ++- .../fastcomments/model/QueryPredicate.java | 103 ++- .../fastcomments/model/QuestionCondition.java | 103 ++- .../fastcomments/model/QuestionConfig.java | 103 ++- .../com/fastcomments/model/QuestionDatum.java | 103 ++- .../fastcomments/model/QuestionResult.java | 103 ++- .../QuestionResultAggregationOverall.java | 103 ++- .../fastcomments/model/ReactBodyParams.java | 103 ++- .../model/ReactFeedPostResponse.java | 103 ++- .../model/RemoveCommentActionResponse.java | 103 ++- .../model/RenderEmailTemplateBody.java | 103 ++- .../model/RenderEmailTemplateResponse.java | 103 ++- .../model/ReplaceTenantPackageBody.java | 103 ++- .../model/ReplaceTenantUserBody.java | 103 ++- .../model/ResetUserNotificationsResponse.java | 103 ++- .../model/SaveCommentResponseOptimized.java | 103 ++- .../fastcomments/model/SavePollResponse.java | 103 ++- .../model/SetCommentTextParams.java | 103 ++- .../model/SetCommentTextResult.java | 103 ++- .../java/com/fastcomments/model/SpamRule.java | 103 ++- .../model/SubQuestionCondition.java | 103 ++- .../com/fastcomments/model/TOSConfig.java | 103 ++- .../com/fastcomments/model/TenantBadge.java | 103 ++- .../com/fastcomments/model/TenantHashTag.java | 103 ++- .../com/fastcomments/model/TenantPackage.java | 188 ++++- .../model/UnBlockFromCommentParams.java | 103 ++- .../fastcomments/model/UnblockSuccess.java | 103 ++- .../model/UpdatableCommentParams.java | 103 ++- .../model/UpdateDomainConfigParams.java | 103 ++- .../model/UpdateEmailTemplateBody.java | 103 ++- .../model/UpdateFeedPostParams.java | 103 ++- .../fastcomments/model/UpdateHashTagBody.java | 103 ++- .../model/UpdateHashTagResponse.java | 103 ++- .../fastcomments/model/UpdateTenantBody.java | 103 ++- .../model/UpdateTenantPackageBody.java | 103 ++- .../model/UpdateTenantUserBody.java | 103 ++- .../model/UpdateUserBadgeParams.java | 103 ++- .../model/UploadImageResponse.java | 103 ++- .../java/com/fastcomments/model/User.java | 103 ++- .../com/fastcomments/model/UserBadge.java | 103 ++- .../fastcomments/model/UserBadgeProgress.java | 103 ++- .../fastcomments/model/UserNotification.java | 103 ++- .../model/UserNotificationCount.java | 103 ++- .../model/UserNotificationWriteResponse.java | 103 ++- .../model/UserReactsResponse.java | 103 ++- .../fastcomments/model/UserSearchResult.java | 103 ++- .../model/UserSearchSectionResult.java | 103 ++- .../fastcomments/model/UserSessionInfo.java | 103 ++- .../fastcomments/model/VoteBodyParams.java | 103 ++- .../model/VoteDeleteResponse.java | 103 ++- .../com/fastcomments/model/VotePollBody.java | 103 ++- .../fastcomments/model/VotePollResponse.java | 103 ++- .../com/fastcomments/model/VoteResponse.java | 103 ++- .../fastcomments/model/VoteResponseUser.java | 103 ++- .../fastcomments/model/WebhookComment.java | 152 +++- .../model/CustomConfigParametersTest.java | 16 + .../fastcomments/model/TenantPackageTest.java | 24 + .../model/WebhookCommentTest.java | 9 + config.json | 2 +- .../UnknownResponseFieldsTest.java | 27 + openapi.json | 759 +++++++---------- pubsub/README.md | 4 +- 258 files changed, 22950 insertions(+), 3605 deletions(-) create mode 100644 core/src/test/java/com/fastcomments/UnknownResponseFieldsTest.java diff --git a/README.md b/README.md index 6540e87b..21f802ea 100644 --- a/README.md +++ b/README.md @@ -37,21 +37,21 @@ Then add the dependencies you need: com.fastcomments client - 3.1.1 + 3.1.2 com.fastcomments core - 3.1.1 + 3.1.2 com.fastcomments pubsub - 3.1.1 + 3.1.2 ``` @@ -70,13 +70,13 @@ repositories { dependencies { // API Client - implementation "com.fastcomments:client:3.1.1" + implementation "com.fastcomments:client:3.1.2" // Core Library (includes SSO) - implementation "com.fastcomments:core:3.1.1" + implementation "com.fastcomments:core:3.1.2" // PubSub Library (for live events) - implementation "com.fastcomments:pubsub:3.1.1" + implementation "com.fastcomments:pubsub:3.1.2" } ``` diff --git a/client/README.md b/client/README.md index fab1d769..96d9706e 100644 --- a/client/README.md +++ b/client/README.md @@ -40,7 +40,7 @@ Add this dependency to your project's POM: com.fastcomments client - 3.1.1 + 3.1.2 compile ``` @@ -56,7 +56,7 @@ Add this dependency to your project's build file: } dependencies { - implementation "com.fastcomments:client:3.1.1" + implementation "com.fastcomments:client:3.1.2" } ``` @@ -70,7 +70,7 @@ mvn clean package Then manually install the following JARs: -* `target/client-3.1.1.jar` +* `target/client-3.1.2.jar` * `target/lib/*.jar` ## Getting Started diff --git a/client/api/openapi.yaml b/client/api/openapi.yaml index 2d73d984..b64b95ad 100644 --- a/client/api/openapi.yaml +++ b/client/api/openapi.yaml @@ -11388,7 +11388,6 @@ components: - onThisSite type: string UserSearchResult: - additionalProperties: false example: displayName: displayName name: name @@ -11416,7 +11415,6 @@ components: - type type: object UserSearchSectionResult: - additionalProperties: false example: section: moderators users: @@ -11554,7 +11552,6 @@ components: - 2 type: integer SpamRule: - additionalProperties: false example: commentContains: commentContains actions: @@ -11625,7 +11622,6 @@ components: - 3 type: integer TOSConfig: - additionalProperties: false example: lastUpdated: 2000-01-23T04:56:07.000+00:00 textByLocale: @@ -11652,7 +11648,6 @@ components: - manual type: string CustomConfigParameters: - additionalProperties: false example: disableAutoHashTagCreation: true disableCommenterCommentDelete: true @@ -11756,6 +11751,7 @@ components: ticketFileUploadsEnabled: true maxCommentCharacterLength: 5 useSingleLineCommentInput: true + autoVerifySimpleSSOComments: true allowedLanguages: - allowedLanguages - allowedLanguages @@ -11764,6 +11760,7 @@ components: widgetQuestionResultsStyle: 2 showLiveRightAway: true widgetQuestionsRequired: 1 + allowSimpleSSOAdmins: true hasDarkBackground: true wrap: true ticketBaseUrl: ticketBaseUrl @@ -11783,10 +11780,18 @@ components: type: string nullable: true type: array + allowSimpleSSOAdmins: + description: "Simple SSO users on this page or domain can be admins and\ + \ moderators: they keep those flags and pick them up from a matching email." + type: boolean autoGenerateUsername: description: Serve each new visitor a unique generated username as the prefilled defaultUsername. type: boolean + autoVerifySimpleSSOComments: + description: "Comments from Simple SSO users on this page or domain are\ + \ verified right away, instead of through an emailed link." + type: boolean collapseReplies: type: boolean commentCountFormat: @@ -12004,7 +12009,6 @@ components: nullable: true type: object APIError: - additionalProperties: false example: reason: reason code: code @@ -12112,6 +12116,7 @@ components: ticketFileUploadsEnabled: true maxCommentCharacterLength: 5 useSingleLineCommentInput: true + autoVerifySimpleSSOComments: true allowedLanguages: - allowedLanguages - allowedLanguages @@ -12120,6 +12125,7 @@ components: widgetQuestionResultsStyle: 2 showLiveRightAway: true widgetQuestionsRequired: 1 + allowSimpleSSOAdmins: true hasDarkBackground: true wrap: true ticketBaseUrl: ticketBaseUrl @@ -12382,7 +12388,6 @@ components: - status type: object ResetUserNotificationsResponse: - additionalProperties: false example: code: ignored-since-impersonated status: success @@ -12398,7 +12403,6 @@ components: - status type: object GetUserNotificationCountResponse: - additionalProperties: false example: count: 0 status: success @@ -12416,7 +12420,6 @@ components: properties: {} type: object NotificationAndCount: - additionalProperties: false properties: type: $ref: "#/components/schemas/NotificationType" @@ -12428,7 +12431,6 @@ components: - type type: object HeaderAccountNotification: - additionalProperties: false properties: _id: type: string @@ -12472,7 +12474,6 @@ components: - title type: object HeaderState: - additionalProperties: false properties: status: $ref: "#/components/schemas/APIStatus" @@ -12500,7 +12501,6 @@ components: - userIdWS type: object UserNotificationWriteResponse: - additionalProperties: false example: modifiedCount: 6 matchedCount: 0 @@ -12520,7 +12520,6 @@ components: - status type: object IgnoredResponse: - additionalProperties: false properties: status: $ref: "#/components/schemas/APIStatus" @@ -12534,7 +12533,6 @@ components: - status type: object MediaAsset: - additionalProperties: false example: src: src w: 0 @@ -12554,7 +12552,6 @@ components: - w type: object UploadImageResponse: - additionalProperties: false example: reason: reason code: code @@ -12795,7 +12792,6 @@ components: - users type: object CommentPollOption: - additionalProperties: false example: votes: 0 id: id @@ -12824,7 +12820,6 @@ components: - 2 type: integer CommentPoll: - additionalProperties: false description: A poll attached to a comment. Vote counts are denormalized here; individual votes live in PollVote. example: @@ -12867,7 +12862,6 @@ components: - totalVotes type: object VotePollResponse: - additionalProperties: false example: myPollVotes: - myPollVotes @@ -12905,7 +12899,6 @@ components: - voterId type: object VotePollBody: - additionalProperties: false example: optionId: optionId properties: @@ -12915,7 +12908,6 @@ components: - optionId type: object PollVoterEntry: - additionalProperties: false example: optionLabel: optionLabel name: name @@ -12929,7 +12921,6 @@ components: - optionLabel type: object GetPollVoterNamesSuccessResponse: - additionalProperties: false example: total: 1 voters: @@ -13143,7 +13134,6 @@ components: DeleteV2PageReact: $ref: "#/components/schemas/CreateV1PageReact" ModerationFilter: - additionalProperties: false example: flagCountGt: 7.061401241503109 approved: true @@ -13199,7 +13189,6 @@ components: type: string type: object BuildModerationFilterResponse: - additionalProperties: false properties: status: type: string @@ -13227,7 +13216,6 @@ components: - userId type: object ModerationAPICountCommentsResponse: - additionalProperties: false example: count: 0.8008281904610115 status: success @@ -13265,7 +13253,6 @@ components: UserId: type: string CommentUserBadgeInfo: - additionalProperties: false example: displayLabel: displayLabel backgroundColor: backgroundColor @@ -13308,7 +13295,6 @@ components: - type type: object ModerationAPIComment: - additionalProperties: false example: date: 2000-01-23T04:56:07.000+00:00 votesDown: 5.962133916683182 @@ -13504,7 +13490,6 @@ components: - verified type: object ModerationAPIGetCommentsResponse: - additionalProperties: false example: moderationFilter: flagCountGt: 7.061401241503109 @@ -13658,7 +13643,6 @@ components: status: $ref: "#/components/schemas/APIStatus" translations: - additionalProperties: false type: object comments: items: @@ -13672,7 +13656,6 @@ components: - translations type: object ModerationExportResponse: - additionalProperties: false example: batchJobId: batchJobId status: status @@ -13686,7 +13669,6 @@ components: - status type: object ModerationExportStatusResponse: - additionalProperties: false example: jobStatus: jobStatus recordCount: 0 @@ -13708,7 +13690,6 @@ components: - status type: object ModerationUserSearchProjected: - additionalProperties: false example: displayName: displayName avatarSrc: avatarSrc @@ -13753,7 +13734,6 @@ components: - users type: object ModerationPageSearchProjected: - additionalProperties: false example: urlId: urlId title: title @@ -13799,7 +13779,6 @@ components: - status type: object ModerationSiteSearchProjected: - additionalProperties: false example: logoSrc100px: logoSrc100px domain: domain @@ -13846,7 +13825,6 @@ components: - status type: object ModerationSuggestResponse: - additionalProperties: false example: pages: - urlId: urlId @@ -13885,7 +13863,6 @@ components: - status type: object PreBanSummary: - additionalProperties: false example: count: 0.8008281904610115 usernames: @@ -13908,7 +13885,6 @@ components: - usernames type: object BulkPreBanSummary: - additionalProperties: false example: emails: - emails @@ -13955,7 +13931,6 @@ components: - userIds type: object BulkPreBanParams: - additionalProperties: false example: commentIds: - commentIds @@ -13969,7 +13944,6 @@ components: - commentIds type: object APIBannedUser: - additionalProperties: false example: bannedUntil: 2000-01-23T04:56:07.000+00:00 ipHash: ipHash @@ -14029,7 +14003,6 @@ components: - tenantId type: object APIBanUserChangedValues: - additionalProperties: false example: bannedUntil: 2000-01-23T04:56:07.000+00:00 ipHash: ipHash @@ -14080,7 +14053,6 @@ components: type: string type: object APIBanUserChangeLog: - additionalProperties: false example: deletedBannedUsers: - bannedUntil: 2000-01-23T04:56:07.000+00:00 @@ -14138,7 +14110,6 @@ components: $ref: "#/components/schemas/APIBanUserChangedValues" type: object BanUserFromCommentResult: - additionalProperties: false example: reason: reason code: code @@ -14207,7 +14178,6 @@ components: - IP type: string BannedUserMatch: - additionalProperties: false example: matchedOn: userId matchedOnValue: BannedUserMatch_matchedOnValue @@ -14221,7 +14191,6 @@ components: - matchedOnValue type: object APICommentCommonBannedUser: - additionalProperties: false properties: _id: type: string @@ -14332,7 +14301,6 @@ components: - status type: object BanUserUndoParams: - additionalProperties: false example: changelog: deletedBannedUsers: @@ -14404,7 +14372,6 @@ components: - status type: object RemoveCommentActionResponse: - additionalProperties: false properties: status: type: string @@ -14427,7 +14394,6 @@ components: - status type: object ModerationAPICommentLog: - additionalProperties: false example: date: 2000-01-23T04:56:07.000+00:00 messageHTML: messageHTML @@ -14692,7 +14658,6 @@ components: - status type: object CommentsByIdsParams: - additionalProperties: false example: ids: - ids @@ -14732,7 +14697,6 @@ components: - status type: object SetCommentTextParams: - additionalProperties: false example: comment: comment properties: @@ -14742,7 +14706,6 @@ components: - comment type: object AdjustVotesResponse: - additionalProperties: false example: newCommentVotes: 0 status: status @@ -14757,7 +14720,6 @@ components: - status type: object AdjustCommentVotesParams: - additionalProperties: false example: adjustVoteAmount: 0.8008281904610115 properties: @@ -14768,7 +14730,6 @@ components: - adjustVoteAmount type: object VoteResponseUser: - additionalProperties: false example: sessionId: sessionId properties: @@ -14777,7 +14738,6 @@ components: type: string type: object VoteResponse: - additionalProperties: false example: editKey: editKey isVerified: true @@ -14804,7 +14764,6 @@ components: - status type: object VoteDeleteResponse: - additionalProperties: false example: wasPendingVote: true status: success @@ -14817,7 +14776,6 @@ components: - status type: object GetCommentBanStatusResponse: - additionalProperties: false example: emailDomain: emailDomain canIPBan: true @@ -14837,7 +14795,6 @@ components: - status type: object APIModerateUserBanPreferences: - additionalProperties: false properties: shouldBanEmail: type: boolean @@ -14869,7 +14826,6 @@ components: - status type: object TenantBadge: - additionalProperties: false example: displayLabel: displayLabel createdByUserId: createdByUserId @@ -15025,7 +14981,6 @@ components: - status type: object UserBadge: - additionalProperties: false example: displayLabel: displayLabel backgroundColor: backgroundColor @@ -15354,7 +15309,6 @@ components: - status type: object FeedPostMediaItemAsset: - additionalProperties: false example: src: src w: 6 @@ -15374,7 +15328,6 @@ components: - w type: object FeedPostMediaItem: - additionalProperties: false example: sizes: - src: src @@ -15398,7 +15351,6 @@ components: - sizes type: object FeedPostLink: - additionalProperties: false example: description: description text: text @@ -15421,7 +15373,6 @@ components: properties: {} type: object FeedPost: - additionalProperties: false example: fromUserDisplayName: fromUserDisplayName fromUserId: fromUserId @@ -15529,7 +15480,6 @@ components: - tenantId type: object UserSessionInfo: - additionalProperties: false properties: id: type: string @@ -15568,7 +15518,6 @@ components: type: string type: object GetPublicFeedPostsResponse: - additionalProperties: false properties: status: $ref: "#/components/schemas/APIStatus" @@ -15716,7 +15665,6 @@ components: tenantIdWS: tenantIdWS status: success ReactFeedPostResponse: - additionalProperties: false example: isUndo: true reactType: reactType @@ -15734,7 +15682,6 @@ components: - status type: object ReactBodyParams: - additionalProperties: false example: reactType: reactType properties: @@ -15742,7 +15689,6 @@ components: type: string type: object UserReactsResponse: - additionalProperties: false example: reacts: key: @@ -15764,7 +15710,6 @@ components: - status type: object CreateFeedPostResponse: - additionalProperties: false example: feedPost: fromUserDisplayName: fromUserDisplayName @@ -15824,7 +15769,6 @@ components: - status type: object CreateFeedPostParams: - additionalProperties: false example: fromUserDisplayName: fromUserDisplayName fromUserId: fromUserId @@ -15893,7 +15837,6 @@ components: type: object type: object UpdateFeedPostParams: - additionalProperties: false example: meta: key: meta @@ -15956,7 +15899,6 @@ components: type: object type: object FeedPostStats: - additionalProperties: false example: reacts: key: 0 @@ -15973,7 +15915,6 @@ components: type: integer type: object FeedPostsStatsResponse: - additionalProperties: false example: stats: key: @@ -15994,7 +15935,6 @@ components: - status type: object EventLogEntry: - additionalProperties: false example: createdAt: 2000-01-23T04:56:07.000+00:00 data: data @@ -16087,7 +16027,6 @@ components: TenantId: type: string UserNotification: - additionalProperties: false example: isUnreadMessage: true fromUserAvatarSrc: fromUserAvatarSrc @@ -16199,7 +16138,6 @@ components: - viewed type: object PubSubVote: - additionalProperties: false properties: _id: type: string @@ -16236,7 +16174,6 @@ components: FDomain: type: string PubSubCommentBase: - additionalProperties: false properties: _id: type: string @@ -16410,7 +16347,6 @@ components: CommentPositions: $ref: "#/components/schemas/Record_string._before-string-or-null--after-string-or-null__" LiveEvent: - additionalProperties: false properties: type: $ref: "#/components/schemas/LiveEventType" @@ -16443,7 +16379,6 @@ components: extraInfo: $ref: "#/components/schemas/LiveEvent_extraInfo" config: - additionalProperties: false type: object isClosed: type: boolean @@ -16485,7 +16420,6 @@ components: - status type: object SetCommentTextResult: - additionalProperties: false example: commentHTML: commentHTML approved: true @@ -16514,7 +16448,6 @@ components: - status type: object CommentUserMentionInfo: - additionalProperties: false example: rawTag: rawTag id: id @@ -16540,7 +16473,6 @@ components: - tag type: object CommentUserHashTagInfo: - additionalProperties: false example: retain: true id: id @@ -16562,7 +16494,6 @@ components: - url type: object CommentTextUpdateRequest: - additionalProperties: false example: hashTags: - retain: true @@ -16728,7 +16659,6 @@ components: isSpam: true isByAdmin: true PublicCommentBase: - additionalProperties: false properties: _id: type: string @@ -16831,7 +16761,6 @@ components: properties: {} type: object GetCommentsResponse_PublicComment_: - additionalProperties: false properties: statusCode: format: int32 @@ -17021,6 +16950,7 @@ components: ticketFileUploadsEnabled: true maxCommentCharacterLength: 5 useSingleLineCommentInput: true + autoVerifySimpleSSOComments: true allowedLanguages: - allowedLanguages - allowedLanguages @@ -17029,6 +16959,7 @@ components: widgetQuestionResultsStyle: 2 showLiveRightAway: true widgetQuestionsRequired: 1 + allowSimpleSSOAdmins: true hasDarkBackground: true wrap: true ticketBaseUrl: ticketBaseUrl @@ -17182,7 +17113,6 @@ components: statusCode: 0 status: status SaveCommentResponseOptimized: - additionalProperties: false properties: status: $ref: "#/components/schemas/APIStatus" @@ -17288,7 +17218,6 @@ components: properties: {} type: object CommentPollInput: - additionalProperties: false example: question: question options: @@ -17319,7 +17248,6 @@ components: - question type: object CommentData: - additionalProperties: false example: date: 0 pageTitle: pageTitle @@ -17426,7 +17354,6 @@ components: urlId: type: string meta: - additionalProperties: false type: object moderationGroupIds: items: @@ -17463,7 +17390,6 @@ components: - urlId type: object DeletedCommentResultComment: - additionalProperties: false example: commentHTML: commentHTML isDeleted: true @@ -17522,7 +17448,6 @@ components: - status type: object VoteBodyParams: - additionalProperties: false example: commenterName: commenterName voteDir: up @@ -17550,7 +17475,6 @@ components: - voteDir type: object GetCommentVoteUserNamesSuccessResponse: - additionalProperties: false example: hasMore: true voteUserNames: @@ -17572,7 +17496,6 @@ components: - voteUserNames type: object CommentTranslationPublic: - additionalProperties: false properties: commentHTML: type: string @@ -17591,7 +17514,6 @@ components: properties: {} type: object CommentTranslationsResponse: - additionalProperties: false example: translations: key: "" @@ -17625,7 +17547,6 @@ components: - translations type: object CommentTranslationsRequest: - additionalProperties: false example: commentIds: - commentIds @@ -17659,7 +17580,6 @@ components: - status type: object BlockSuccess: - additionalProperties: false example: commentStatuses: key: true @@ -17678,7 +17598,6 @@ components: - status type: object PublicBlockFromCommentParams: - additionalProperties: false example: commentIds: - commentIds @@ -17695,7 +17614,6 @@ components: - commentIds type: object UnblockSuccess: - additionalProperties: false example: commentStatuses: key: true @@ -17884,7 +17802,6 @@ components: - status type: object APISSOUser: - additionalProperties: false example: displayLabel: displayLabel displayName: displayName @@ -18611,7 +18528,6 @@ components: - domain type: string PageMigration: - additionalProperties: false example: from: from to: to @@ -18736,7 +18652,6 @@ components: - api type: string PublicWebhook: - additionalProperties: false example: disabledReason: auto method: PUT @@ -18797,7 +18712,6 @@ components: - url type: object GetWebhooksResponse: - additionalProperties: false example: webhooks: - disabledReason: auto @@ -18839,7 +18753,6 @@ components: - webhooks type: object WebhookComment: - additionalProperties: false example: date: date pageNumber: 5.962133916683182 @@ -18862,6 +18775,25 @@ components: url: url parentId: parentId commenterEmail: commenterEmail + badges: + - displayLabel: displayLabel + backgroundColor: backgroundColor + borderColor: borderColor + cssClass: cssClass + description: description + id: id + type: 2 + textColor: textColor + displaySrc: displaySrc + - displayLabel: displayLabel + backgroundColor: backgroundColor + borderColor: borderColor + cssClass: cssClass + description: description + id: id + type: 2 + textColor: textColor + displaySrc: displaySrc moderationGroupIds: - moderationGroupIds - moderationGroupIds @@ -18963,10 +18895,15 @@ components: items: type: string type: array + badges: + items: + $ref: "#/components/schemas/CommentUserBadgeInfo" + type: array required: - aiDeterminedSpam - approved - avatarSrc + - badges - comment - commentHTML - commenterEmail @@ -18995,7 +18932,6 @@ components: - votesUp type: object GetWebhookSamplePayloadsResponse: - additionalProperties: false example: payloads: - date: date @@ -19019,6 +18955,25 @@ components: url: url parentId: parentId commenterEmail: commenterEmail + badges: + - displayLabel: displayLabel + backgroundColor: backgroundColor + borderColor: borderColor + cssClass: cssClass + description: description + id: id + type: 2 + textColor: textColor + displaySrc: displaySrc + - displayLabel: displayLabel + backgroundColor: backgroundColor + borderColor: borderColor + cssClass: cssClass + description: description + id: id + type: 2 + textColor: textColor + displaySrc: displaySrc moderationGroupIds: - moderationGroupIds - moderationGroupIds @@ -19060,6 +19015,25 @@ components: url: url parentId: parentId commenterEmail: commenterEmail + badges: + - displayLabel: displayLabel + backgroundColor: backgroundColor + borderColor: borderColor + cssClass: cssClass + description: description + id: id + type: 2 + textColor: textColor + displaySrc: displaySrc + - displayLabel: displayLabel + backgroundColor: backgroundColor + borderColor: borderColor + cssClass: cssClass + description: description + id: id + type: 2 + textColor: textColor + displaySrc: displaySrc moderationGroupIds: - moderationGroupIds - moderationGroupIds @@ -19093,7 +19067,6 @@ components: - status type: object CreateWebhookResponse: - additionalProperties: false example: webhook: disabledReason: auto @@ -19120,7 +19093,6 @@ components: - webhook type: object CreateWebhookParams: - additionalProperties: false example: method: PUT domain: domain @@ -19143,7 +19115,6 @@ components: - url type: object PublicVote: - additionalProperties: false example: createdAt: 2000-01-23T04:56:07.000+00:00 commentId: commentId @@ -19174,7 +19145,6 @@ components: - userId type: object GetVotesResponse: - additionalProperties: false example: appliedAuthorizedVotes: - createdAt: 2000-01-23T04:56:07.000+00:00 @@ -19238,7 +19208,6 @@ components: - status type: object GetVotesForUserResponse: - additionalProperties: false example: appliedAuthorizedVotes: - createdAt: 2000-01-23T04:56:07.000+00:00 @@ -19318,7 +19287,6 @@ components: AgentApprovalNotificationFrequency: $ref: "#/components/schemas/ImportedAgentApprovalNotificationFrequency" User: - additionalProperties: false example: socialLinks: - socialLinks @@ -19539,7 +19507,6 @@ components: - verified type: object GetUserResponse: - additionalProperties: false example: user: socialLinks: @@ -19617,7 +19584,6 @@ components: - user type: object APIGetUserBadgeResponse: - additionalProperties: false example: userBadge: displayLabel: displayLabel @@ -19650,7 +19616,6 @@ components: - userBadge type: object APIGetUserBadgesResponse: - additionalProperties: false example: userBadges: - displayLabel: displayLabel @@ -19704,7 +19669,6 @@ components: - userBadges type: object APICreateUserBadgeResponse: - additionalProperties: false example: userBadge: displayLabel: displayLabel @@ -19744,7 +19708,6 @@ components: - userBadge type: object CreateUserBadgeParams: - additionalProperties: false example: badgeId: badgeId userId: userId @@ -19761,7 +19724,6 @@ components: - userId type: object APIEmptySuccessResponse: - additionalProperties: false example: status: success properties: @@ -19771,7 +19733,6 @@ components: - status type: object UpdateUserBadgeParams: - additionalProperties: false example: displayedOnComments: true properties: @@ -19779,7 +19740,6 @@ components: type: boolean type: object UserBadgeProgress: - additionalProperties: false example: firstCommentDate: 2000-01-23T04:56:07.000+00:00 autoTrustFactor: 0.8008281904610115 @@ -19828,7 +19788,6 @@ components: - userId type: object APIGetUserBadgeProgressResponse: - additionalProperties: false example: userBadgeProgress: firstCommentDate: 2000-01-23T04:56:07.000+00:00 @@ -19852,7 +19811,6 @@ components: - userBadgeProgress type: object APIGetUserBadgeProgressListResponse: - additionalProperties: false example: status: success userBadgeProgresses: @@ -19888,7 +19846,6 @@ components: - userBadgeProgresses type: object APITicket: - additionalProperties: false example: createdAt: createdAt subject: subject @@ -19936,7 +19893,6 @@ components: - userId type: object GetTicketsResponse: - additionalProperties: false example: tickets: - createdAt: createdAt @@ -19974,7 +19930,6 @@ components: - tickets type: object CreateTicketResponse: - additionalProperties: false example: ticket: createdAt: createdAt @@ -19999,7 +19954,6 @@ components: - ticket type: object CreateTicketBody: - additionalProperties: false example: subject: subject properties: @@ -20009,7 +19963,6 @@ components: - subject type: object APITicketFile: - additionalProperties: false example: originalFileName: originalFileName s3Key: s3Key @@ -20055,7 +20008,6 @@ components: - url type: object APITicketDetail: - additionalProperties: false example: resolvedAt: resolvedAt subject: subject @@ -20141,7 +20093,6 @@ components: - userId type: object GetTicketResponse: - additionalProperties: false example: availableStates: - 5.962133916683182 @@ -20199,7 +20150,6 @@ components: - ticket type: object ChangeTicketStateResponse: - additionalProperties: false example: ticket: createdAt: createdAt @@ -20224,7 +20174,6 @@ components: - ticket type: object ChangeTicketStateBody: - additionalProperties: false example: state: 0 properties: @@ -20243,7 +20192,6 @@ components: SiteType: $ref: "#/components/schemas/ImportedSiteType" APIDomainConfiguration: - additionalProperties: false example: emailFromEmail: emailFromEmail footerUnsubscribeURL: footerUnsubscribeURL @@ -20311,7 +20259,6 @@ components: - id type: object BillingInfo: - additionalProperties: false example: zip: zip country: country @@ -20356,7 +20303,6 @@ components: - zip type: object APITenant: - additionalProperties: false example: enableProfanityFilter: true paymentFrequency: 6.027456183070403 @@ -20516,7 +20462,6 @@ components: - signUpDate type: object GetTenantResponse: - additionalProperties: false example: tenant: enableProfanityFilter: true @@ -20601,7 +20546,6 @@ components: - tenant type: object GetTenantsResponse: - additionalProperties: false example: tenants: - enableProfanityFilter: true @@ -20759,7 +20703,6 @@ components: - tenants type: object CreateTenantResponse: - additionalProperties: false example: tenant: enableProfanityFilter: true @@ -20844,7 +20787,6 @@ components: - tenant type: object CreateTenantBody: - additionalProperties: false example: enableProfanityFilter: true stripePlanId: stripePlanId @@ -20971,7 +20913,6 @@ components: - name type: object UpdateTenantBody: - additionalProperties: false example: enableProfanityFilter: true stripePlanId: stripePlanId @@ -21098,7 +21039,6 @@ components: type: string type: object GetTenantUserResponse: - additionalProperties: false example: tenantUser: socialLinks: @@ -21176,7 +21116,6 @@ components: - tenantUser type: object GetTenantUsersResponse: - additionalProperties: false example: tenantUsers: - socialLinks: @@ -21320,7 +21259,6 @@ components: - tenantUsers type: object CreateTenantUserResponse: - additionalProperties: false example: tenantUser: socialLinks: @@ -21398,7 +21336,6 @@ components: - tenantUser type: object CreateTenantUserBody: - additionalProperties: false example: isHelpRequestAdmin: true displayLabel: displayLabel @@ -21485,7 +21422,6 @@ components: - username type: object ReplaceTenantUserBody: - additionalProperties: false example: isHelpRequestAdmin: true displayName: displayName @@ -21586,7 +21522,6 @@ components: - username type: object UpdateTenantUserBody: - additionalProperties: false example: isHelpRequestAdmin: true displayLabel: displayLabel @@ -21670,55 +21605,57 @@ components: type: string type: object TenantPackage: - additionalProperties: false example: - maxMonthlySmallWidgetsCredits: 5.637376656633329 - flexAPICreditCostCents: 9.965781217890562 - flexMinimumCostCents: 3.353193347011243 - flexCommentUnit: 1.1730742509559433 - maxMonthlyAPICredits: 5.962133916683182 + maxMonthlySmallWidgetsCredits: 7.061401241503109 + flexAPICreditCostCents: 6.683562403749608 + flexMinimumCostCents: 7.143538047012306 + monthlyCostLocal: 1.4658129805029452 + flexCommentUnit: 5.025004791520295 + maxMonthlyAPICredits: 2.3021358869347655 templateId: templateId createdAt: 2000-01-23T04:56:07.000+00:00 - flexManagedTenantCostCents: 3.0937452626664474 - flexSmallWidgetsCreditUnit: 8.762042012749001 + flexManagedTenantCostCents: 0.8851374739011653 + flexSmallWidgetsCreditUnit: 6.438423552598547 yearlyStripePlanId: yearlyStripePlanId - aiAgentDailyBudgetCents: 8.969578798196912 - maxSSOUsers: 3.616076749251911 + aiAgentDailyBudgetCents: 3.0205796992916243 + maxSSOUsers: 4.145608029883936 hasFlexPricing: true - flexSSOModeratorCostCents: 7.058770351582356 + flexSSOModeratorCostCents: 0.10263654006109402 monthlyCostUSD: 0.8008281904610115 - maxTenantUsers: 9.301444243932576 - maxCustomCollectionSize: 1.0246457001441578 + maxTenantUsers: 2.027123023002322 + maxCustomCollectionSize: 6.84685269835264 enableSAML: true enableCanvasLTI: true forWhoText: forWhoText - flexAPICreditUnit: 9.369310271410669 - flexAdminCostCents: 3.5571952270680973 - maxConcurrentUsers: 7.061401241503109 - flexLLMCostCents: 5.944895607614016 + flexAPICreditUnit: 8.762042012749001 + flexAdminCostCents: 1.284659006116532 + maxConcurrentUsers: 3.616076749251911 + flexLLMCostCents: 3.353193347011243 name: name _id: _id - aiAgentMonthlyBudgetCents: 7.740351818741173 - flexModeratorUnit: 6.438423552598547 - flexChatGPTCostCents: 6.778324963048013 - flexSSOAdminCostCents: 7.143538047012306 - flexSSOUserCostCents: 4.965218492984954 - flexLLMUnit: 6.704019297950036 - flexFreeModerators: 0.10263654006109402 - flexSSOModeratorUnit: 6.519180951018382 - maxDomains: 4.145608029883936 - maxMonthlyEventLogRequests: 1.2315135367772556 - maxAIAgents: 4.652396432933246 - flexDomainUnit: 2.8841621266687802 + aiAgentMonthlyBudgetCents: 3.0576100241049344 + yearlyCostLocal: 5.962133916683182 + flexModeratorUnit: 6.965117697638846 + flexChatGPTCostCents: 5.944895607614016 + pricingCurrency: pricingCurrency + flexSSOAdminCostCents: 7.058770351582356 + flexSSOUserCostCents: 9.965781217890562 + flexLLMUnit: 3.0937452626664474 + flexFreeModerators: 8.969578798196912 + flexSSOModeratorUnit: 4.652396432933246 + maxDomains: 1.2315135367772556 + maxMonthlyEventLogRequests: 1.4894159098541704 + maxAIAgents: 7.740351818741173 + flexDomainUnit: 6.878052220127876 hasWhiteLabeling: true - flexChatGPTUnit: 6.878052220127876 - maxMonthlyComments: 2.3021358869347655 - maxModerators: 2.027123023002322 + flexChatGPTUnit: 6.704019297950036 + maxMonthlyComments: 9.301444243932576 + maxModerators: 7.386281948385884 hasAuditing: true hasAIAgents: true - flexSSOUserUnit: 5.025004791520295 - maxMonthlyPageLoads: 1.4658129805029452 - flexDomainCostCents: 1.284659006116532 + flexSSOUserUnit: 9.369310271410669 + maxMonthlyPageLoads: 5.637376656633329 + flexDomainCostCents: 6.778324963048013 hasLLMSpamDetection: true isSSOBillingMonthlyActiveUsers: true featureTaglines: @@ -21726,16 +21663,16 @@ components: - featureTaglines yearlyCostUSD: 6.027456183070403 hasDebranding: true - flexPageLoadCostCents: 1.4894159098541704 - flexAdminUnit: 6.965117697638846 - maxWhiteLabeledTenants: 7.386281948385884 - flexSmallWidgetsCreditCostCents: 6.683562403749608 + flexPageLoadCostCents: 7.457744773683766 + flexAdminUnit: 2.8841621266687802 + maxWhiteLabeledTenants: 1.0246457001441578 + flexSmallWidgetsCreditCostCents: 9.018348186070783 tenantId: tenantId - flexCommentCostCents: 7.457744773683766 - flexModeratorCostCents: 9.018348186070783 - flexPageLoadUnit: 6.84685269835264 + flexCommentCostCents: 4.965218492984954 + flexModeratorCostCents: 3.5571952270680973 + flexPageLoadUnit: 1.1730742509559433 monthlyStripePlanId: monthlyStripePlanId - flexSSOAdminUnit: 0.8851374739011653 + flexSSOAdminUnit: 6.519180951018382 properties: _id: type: string @@ -21749,6 +21686,8 @@ components: templateId: type: string monthlyCostUSD: + description: "Always the USD list price, also on regionally priced tenants\ + \ (commissions and plan comparisons read it)." format: double nullable: true type: number @@ -21756,6 +21695,18 @@ components: format: double nullable: true type: number + pricingCurrency: + description: "Regional prices the tenant is charged, when pricingCurrency\ + \ is set; the Stripe plan ids below are then in that currency." + type: string + monthlyCostLocal: + format: double + nullable: true + type: number + yearlyCostLocal: + format: double + nullable: true + type: number monthlyStripePlanId: nullable: true type: string @@ -21942,56 +21893,58 @@ components: - yearlyStripePlanId type: object GetTenantPackageResponse: - additionalProperties: false example: tenantPackage: - maxMonthlySmallWidgetsCredits: 5.637376656633329 - flexAPICreditCostCents: 9.965781217890562 - flexMinimumCostCents: 3.353193347011243 - flexCommentUnit: 1.1730742509559433 - maxMonthlyAPICredits: 5.962133916683182 + maxMonthlySmallWidgetsCredits: 7.061401241503109 + flexAPICreditCostCents: 6.683562403749608 + flexMinimumCostCents: 7.143538047012306 + monthlyCostLocal: 1.4658129805029452 + flexCommentUnit: 5.025004791520295 + maxMonthlyAPICredits: 2.3021358869347655 templateId: templateId createdAt: 2000-01-23T04:56:07.000+00:00 - flexManagedTenantCostCents: 3.0937452626664474 - flexSmallWidgetsCreditUnit: 8.762042012749001 + flexManagedTenantCostCents: 0.8851374739011653 + flexSmallWidgetsCreditUnit: 6.438423552598547 yearlyStripePlanId: yearlyStripePlanId - aiAgentDailyBudgetCents: 8.969578798196912 - maxSSOUsers: 3.616076749251911 + aiAgentDailyBudgetCents: 3.0205796992916243 + maxSSOUsers: 4.145608029883936 hasFlexPricing: true - flexSSOModeratorCostCents: 7.058770351582356 + flexSSOModeratorCostCents: 0.10263654006109402 monthlyCostUSD: 0.8008281904610115 - maxTenantUsers: 9.301444243932576 - maxCustomCollectionSize: 1.0246457001441578 + maxTenantUsers: 2.027123023002322 + maxCustomCollectionSize: 6.84685269835264 enableSAML: true enableCanvasLTI: true forWhoText: forWhoText - flexAPICreditUnit: 9.369310271410669 - flexAdminCostCents: 3.5571952270680973 - maxConcurrentUsers: 7.061401241503109 - flexLLMCostCents: 5.944895607614016 + flexAPICreditUnit: 8.762042012749001 + flexAdminCostCents: 1.284659006116532 + maxConcurrentUsers: 3.616076749251911 + flexLLMCostCents: 3.353193347011243 name: name _id: _id - aiAgentMonthlyBudgetCents: 7.740351818741173 - flexModeratorUnit: 6.438423552598547 - flexChatGPTCostCents: 6.778324963048013 - flexSSOAdminCostCents: 7.143538047012306 - flexSSOUserCostCents: 4.965218492984954 - flexLLMUnit: 6.704019297950036 - flexFreeModerators: 0.10263654006109402 - flexSSOModeratorUnit: 6.519180951018382 - maxDomains: 4.145608029883936 - maxMonthlyEventLogRequests: 1.2315135367772556 - maxAIAgents: 4.652396432933246 - flexDomainUnit: 2.8841621266687802 + aiAgentMonthlyBudgetCents: 3.0576100241049344 + yearlyCostLocal: 5.962133916683182 + flexModeratorUnit: 6.965117697638846 + flexChatGPTCostCents: 5.944895607614016 + pricingCurrency: pricingCurrency + flexSSOAdminCostCents: 7.058770351582356 + flexSSOUserCostCents: 9.965781217890562 + flexLLMUnit: 3.0937452626664474 + flexFreeModerators: 8.969578798196912 + flexSSOModeratorUnit: 4.652396432933246 + maxDomains: 1.2315135367772556 + maxMonthlyEventLogRequests: 1.4894159098541704 + maxAIAgents: 7.740351818741173 + flexDomainUnit: 6.878052220127876 hasWhiteLabeling: true - flexChatGPTUnit: 6.878052220127876 - maxMonthlyComments: 2.3021358869347655 - maxModerators: 2.027123023002322 + flexChatGPTUnit: 6.704019297950036 + maxMonthlyComments: 9.301444243932576 + maxModerators: 7.386281948385884 hasAuditing: true hasAIAgents: true - flexSSOUserUnit: 5.025004791520295 - maxMonthlyPageLoads: 1.4658129805029452 - flexDomainCostCents: 1.284659006116532 + flexSSOUserUnit: 9.369310271410669 + maxMonthlyPageLoads: 5.637376656633329 + flexDomainCostCents: 6.778324963048013 hasLLMSpamDetection: true isSSOBillingMonthlyActiveUsers: true featureTaglines: @@ -21999,16 +21952,16 @@ components: - featureTaglines yearlyCostUSD: 6.027456183070403 hasDebranding: true - flexPageLoadCostCents: 1.4894159098541704 - flexAdminUnit: 6.965117697638846 - maxWhiteLabeledTenants: 7.386281948385884 - flexSmallWidgetsCreditCostCents: 6.683562403749608 + flexPageLoadCostCents: 7.457744773683766 + flexAdminUnit: 2.8841621266687802 + maxWhiteLabeledTenants: 1.0246457001441578 + flexSmallWidgetsCreditCostCents: 9.018348186070783 tenantId: tenantId - flexCommentCostCents: 7.457744773683766 - flexModeratorCostCents: 9.018348186070783 - flexPageLoadUnit: 6.84685269835264 + flexCommentCostCents: 4.965218492984954 + flexModeratorCostCents: 3.5571952270680973 + flexPageLoadUnit: 1.1730742509559433 monthlyStripePlanId: monthlyStripePlanId - flexSSOAdminUnit: 0.8851374739011653 + flexSSOAdminUnit: 6.519180951018382 status: success properties: status: @@ -22020,56 +21973,58 @@ components: - tenantPackage type: object GetTenantPackagesResponse: - additionalProperties: false example: tenantPackages: - - maxMonthlySmallWidgetsCredits: 5.637376656633329 - flexAPICreditCostCents: 9.965781217890562 - flexMinimumCostCents: 3.353193347011243 - flexCommentUnit: 1.1730742509559433 - maxMonthlyAPICredits: 5.962133916683182 + - maxMonthlySmallWidgetsCredits: 7.061401241503109 + flexAPICreditCostCents: 6.683562403749608 + flexMinimumCostCents: 7.143538047012306 + monthlyCostLocal: 1.4658129805029452 + flexCommentUnit: 5.025004791520295 + maxMonthlyAPICredits: 2.3021358869347655 templateId: templateId createdAt: 2000-01-23T04:56:07.000+00:00 - flexManagedTenantCostCents: 3.0937452626664474 - flexSmallWidgetsCreditUnit: 8.762042012749001 + flexManagedTenantCostCents: 0.8851374739011653 + flexSmallWidgetsCreditUnit: 6.438423552598547 yearlyStripePlanId: yearlyStripePlanId - aiAgentDailyBudgetCents: 8.969578798196912 - maxSSOUsers: 3.616076749251911 + aiAgentDailyBudgetCents: 3.0205796992916243 + maxSSOUsers: 4.145608029883936 hasFlexPricing: true - flexSSOModeratorCostCents: 7.058770351582356 + flexSSOModeratorCostCents: 0.10263654006109402 monthlyCostUSD: 0.8008281904610115 - maxTenantUsers: 9.301444243932576 - maxCustomCollectionSize: 1.0246457001441578 + maxTenantUsers: 2.027123023002322 + maxCustomCollectionSize: 6.84685269835264 enableSAML: true enableCanvasLTI: true forWhoText: forWhoText - flexAPICreditUnit: 9.369310271410669 - flexAdminCostCents: 3.5571952270680973 - maxConcurrentUsers: 7.061401241503109 - flexLLMCostCents: 5.944895607614016 + flexAPICreditUnit: 8.762042012749001 + flexAdminCostCents: 1.284659006116532 + maxConcurrentUsers: 3.616076749251911 + flexLLMCostCents: 3.353193347011243 name: name _id: _id - aiAgentMonthlyBudgetCents: 7.740351818741173 - flexModeratorUnit: 6.438423552598547 - flexChatGPTCostCents: 6.778324963048013 - flexSSOAdminCostCents: 7.143538047012306 - flexSSOUserCostCents: 4.965218492984954 - flexLLMUnit: 6.704019297950036 - flexFreeModerators: 0.10263654006109402 - flexSSOModeratorUnit: 6.519180951018382 - maxDomains: 4.145608029883936 - maxMonthlyEventLogRequests: 1.2315135367772556 - maxAIAgents: 4.652396432933246 - flexDomainUnit: 2.8841621266687802 + aiAgentMonthlyBudgetCents: 3.0576100241049344 + yearlyCostLocal: 5.962133916683182 + flexModeratorUnit: 6.965117697638846 + flexChatGPTCostCents: 5.944895607614016 + pricingCurrency: pricingCurrency + flexSSOAdminCostCents: 7.058770351582356 + flexSSOUserCostCents: 9.965781217890562 + flexLLMUnit: 3.0937452626664474 + flexFreeModerators: 8.969578798196912 + flexSSOModeratorUnit: 4.652396432933246 + maxDomains: 1.2315135367772556 + maxMonthlyEventLogRequests: 1.4894159098541704 + maxAIAgents: 7.740351818741173 + flexDomainUnit: 6.878052220127876 hasWhiteLabeling: true - flexChatGPTUnit: 6.878052220127876 - maxMonthlyComments: 2.3021358869347655 - maxModerators: 2.027123023002322 + flexChatGPTUnit: 6.704019297950036 + maxMonthlyComments: 9.301444243932576 + maxModerators: 7.386281948385884 hasAuditing: true hasAIAgents: true - flexSSOUserUnit: 5.025004791520295 - maxMonthlyPageLoads: 1.4658129805029452 - flexDomainCostCents: 1.284659006116532 + flexSSOUserUnit: 9.369310271410669 + maxMonthlyPageLoads: 5.637376656633329 + flexDomainCostCents: 6.778324963048013 hasLLMSpamDetection: true isSSOBillingMonthlyActiveUsers: true featureTaglines: @@ -22077,63 +22032,66 @@ components: - featureTaglines yearlyCostUSD: 6.027456183070403 hasDebranding: true - flexPageLoadCostCents: 1.4894159098541704 - flexAdminUnit: 6.965117697638846 - maxWhiteLabeledTenants: 7.386281948385884 - flexSmallWidgetsCreditCostCents: 6.683562403749608 + flexPageLoadCostCents: 7.457744773683766 + flexAdminUnit: 2.8841621266687802 + maxWhiteLabeledTenants: 1.0246457001441578 + flexSmallWidgetsCreditCostCents: 9.018348186070783 tenantId: tenantId - flexCommentCostCents: 7.457744773683766 - flexModeratorCostCents: 9.018348186070783 - flexPageLoadUnit: 6.84685269835264 + flexCommentCostCents: 4.965218492984954 + flexModeratorCostCents: 3.5571952270680973 + flexPageLoadUnit: 1.1730742509559433 monthlyStripePlanId: monthlyStripePlanId - flexSSOAdminUnit: 0.8851374739011653 - - maxMonthlySmallWidgetsCredits: 5.637376656633329 - flexAPICreditCostCents: 9.965781217890562 - flexMinimumCostCents: 3.353193347011243 - flexCommentUnit: 1.1730742509559433 - maxMonthlyAPICredits: 5.962133916683182 + flexSSOAdminUnit: 6.519180951018382 + - maxMonthlySmallWidgetsCredits: 7.061401241503109 + flexAPICreditCostCents: 6.683562403749608 + flexMinimumCostCents: 7.143538047012306 + monthlyCostLocal: 1.4658129805029452 + flexCommentUnit: 5.025004791520295 + maxMonthlyAPICredits: 2.3021358869347655 templateId: templateId createdAt: 2000-01-23T04:56:07.000+00:00 - flexManagedTenantCostCents: 3.0937452626664474 - flexSmallWidgetsCreditUnit: 8.762042012749001 + flexManagedTenantCostCents: 0.8851374739011653 + flexSmallWidgetsCreditUnit: 6.438423552598547 yearlyStripePlanId: yearlyStripePlanId - aiAgentDailyBudgetCents: 8.969578798196912 - maxSSOUsers: 3.616076749251911 + aiAgentDailyBudgetCents: 3.0205796992916243 + maxSSOUsers: 4.145608029883936 hasFlexPricing: true - flexSSOModeratorCostCents: 7.058770351582356 + flexSSOModeratorCostCents: 0.10263654006109402 monthlyCostUSD: 0.8008281904610115 - maxTenantUsers: 9.301444243932576 - maxCustomCollectionSize: 1.0246457001441578 + maxTenantUsers: 2.027123023002322 + maxCustomCollectionSize: 6.84685269835264 enableSAML: true enableCanvasLTI: true forWhoText: forWhoText - flexAPICreditUnit: 9.369310271410669 - flexAdminCostCents: 3.5571952270680973 - maxConcurrentUsers: 7.061401241503109 - flexLLMCostCents: 5.944895607614016 + flexAPICreditUnit: 8.762042012749001 + flexAdminCostCents: 1.284659006116532 + maxConcurrentUsers: 3.616076749251911 + flexLLMCostCents: 3.353193347011243 name: name _id: _id - aiAgentMonthlyBudgetCents: 7.740351818741173 - flexModeratorUnit: 6.438423552598547 - flexChatGPTCostCents: 6.778324963048013 - flexSSOAdminCostCents: 7.143538047012306 - flexSSOUserCostCents: 4.965218492984954 - flexLLMUnit: 6.704019297950036 - flexFreeModerators: 0.10263654006109402 - flexSSOModeratorUnit: 6.519180951018382 - maxDomains: 4.145608029883936 - maxMonthlyEventLogRequests: 1.2315135367772556 - maxAIAgents: 4.652396432933246 - flexDomainUnit: 2.8841621266687802 + aiAgentMonthlyBudgetCents: 3.0576100241049344 + yearlyCostLocal: 5.962133916683182 + flexModeratorUnit: 6.965117697638846 + flexChatGPTCostCents: 5.944895607614016 + pricingCurrency: pricingCurrency + flexSSOAdminCostCents: 7.058770351582356 + flexSSOUserCostCents: 9.965781217890562 + flexLLMUnit: 3.0937452626664474 + flexFreeModerators: 8.969578798196912 + flexSSOModeratorUnit: 4.652396432933246 + maxDomains: 1.2315135367772556 + maxMonthlyEventLogRequests: 1.4894159098541704 + maxAIAgents: 7.740351818741173 + flexDomainUnit: 6.878052220127876 hasWhiteLabeling: true - flexChatGPTUnit: 6.878052220127876 - maxMonthlyComments: 2.3021358869347655 - maxModerators: 2.027123023002322 + flexChatGPTUnit: 6.704019297950036 + maxMonthlyComments: 9.301444243932576 + maxModerators: 7.386281948385884 hasAuditing: true hasAIAgents: true - flexSSOUserUnit: 5.025004791520295 - maxMonthlyPageLoads: 1.4658129805029452 - flexDomainCostCents: 1.284659006116532 + flexSSOUserUnit: 9.369310271410669 + maxMonthlyPageLoads: 5.637376656633329 + flexDomainCostCents: 6.778324963048013 hasLLMSpamDetection: true isSSOBillingMonthlyActiveUsers: true featureTaglines: @@ -22141,16 +22099,16 @@ components: - featureTaglines yearlyCostUSD: 6.027456183070403 hasDebranding: true - flexPageLoadCostCents: 1.4894159098541704 - flexAdminUnit: 6.965117697638846 - maxWhiteLabeledTenants: 7.386281948385884 - flexSmallWidgetsCreditCostCents: 6.683562403749608 + flexPageLoadCostCents: 7.457744773683766 + flexAdminUnit: 2.8841621266687802 + maxWhiteLabeledTenants: 1.0246457001441578 + flexSmallWidgetsCreditCostCents: 9.018348186070783 tenantId: tenantId - flexCommentCostCents: 7.457744773683766 - flexModeratorCostCents: 9.018348186070783 - flexPageLoadUnit: 6.84685269835264 + flexCommentCostCents: 4.965218492984954 + flexModeratorCostCents: 3.5571952270680973 + flexPageLoadUnit: 1.1730742509559433 monthlyStripePlanId: monthlyStripePlanId - flexSSOAdminUnit: 0.8851374739011653 + flexSSOAdminUnit: 6.519180951018382 status: success properties: status: @@ -22164,56 +22122,58 @@ components: - tenantPackages type: object CreateTenantPackageResponse: - additionalProperties: false example: tenantPackage: - maxMonthlySmallWidgetsCredits: 5.637376656633329 - flexAPICreditCostCents: 9.965781217890562 - flexMinimumCostCents: 3.353193347011243 - flexCommentUnit: 1.1730742509559433 - maxMonthlyAPICredits: 5.962133916683182 + maxMonthlySmallWidgetsCredits: 7.061401241503109 + flexAPICreditCostCents: 6.683562403749608 + flexMinimumCostCents: 7.143538047012306 + monthlyCostLocal: 1.4658129805029452 + flexCommentUnit: 5.025004791520295 + maxMonthlyAPICredits: 2.3021358869347655 templateId: templateId createdAt: 2000-01-23T04:56:07.000+00:00 - flexManagedTenantCostCents: 3.0937452626664474 - flexSmallWidgetsCreditUnit: 8.762042012749001 + flexManagedTenantCostCents: 0.8851374739011653 + flexSmallWidgetsCreditUnit: 6.438423552598547 yearlyStripePlanId: yearlyStripePlanId - aiAgentDailyBudgetCents: 8.969578798196912 - maxSSOUsers: 3.616076749251911 + aiAgentDailyBudgetCents: 3.0205796992916243 + maxSSOUsers: 4.145608029883936 hasFlexPricing: true - flexSSOModeratorCostCents: 7.058770351582356 + flexSSOModeratorCostCents: 0.10263654006109402 monthlyCostUSD: 0.8008281904610115 - maxTenantUsers: 9.301444243932576 - maxCustomCollectionSize: 1.0246457001441578 + maxTenantUsers: 2.027123023002322 + maxCustomCollectionSize: 6.84685269835264 enableSAML: true enableCanvasLTI: true forWhoText: forWhoText - flexAPICreditUnit: 9.369310271410669 - flexAdminCostCents: 3.5571952270680973 - maxConcurrentUsers: 7.061401241503109 - flexLLMCostCents: 5.944895607614016 + flexAPICreditUnit: 8.762042012749001 + flexAdminCostCents: 1.284659006116532 + maxConcurrentUsers: 3.616076749251911 + flexLLMCostCents: 3.353193347011243 name: name _id: _id - aiAgentMonthlyBudgetCents: 7.740351818741173 - flexModeratorUnit: 6.438423552598547 - flexChatGPTCostCents: 6.778324963048013 - flexSSOAdminCostCents: 7.143538047012306 - flexSSOUserCostCents: 4.965218492984954 - flexLLMUnit: 6.704019297950036 - flexFreeModerators: 0.10263654006109402 - flexSSOModeratorUnit: 6.519180951018382 - maxDomains: 4.145608029883936 - maxMonthlyEventLogRequests: 1.2315135367772556 - maxAIAgents: 4.652396432933246 - flexDomainUnit: 2.8841621266687802 + aiAgentMonthlyBudgetCents: 3.0576100241049344 + yearlyCostLocal: 5.962133916683182 + flexModeratorUnit: 6.965117697638846 + flexChatGPTCostCents: 5.944895607614016 + pricingCurrency: pricingCurrency + flexSSOAdminCostCents: 7.058770351582356 + flexSSOUserCostCents: 9.965781217890562 + flexLLMUnit: 3.0937452626664474 + flexFreeModerators: 8.969578798196912 + flexSSOModeratorUnit: 4.652396432933246 + maxDomains: 1.2315135367772556 + maxMonthlyEventLogRequests: 1.4894159098541704 + maxAIAgents: 7.740351818741173 + flexDomainUnit: 6.878052220127876 hasWhiteLabeling: true - flexChatGPTUnit: 6.878052220127876 - maxMonthlyComments: 2.3021358869347655 - maxModerators: 2.027123023002322 + flexChatGPTUnit: 6.704019297950036 + maxMonthlyComments: 9.301444243932576 + maxModerators: 7.386281948385884 hasAuditing: true hasAIAgents: true - flexSSOUserUnit: 5.025004791520295 - maxMonthlyPageLoads: 1.4658129805029452 - flexDomainCostCents: 1.284659006116532 + flexSSOUserUnit: 9.369310271410669 + maxMonthlyPageLoads: 5.637376656633329 + flexDomainCostCents: 6.778324963048013 hasLLMSpamDetection: true isSSOBillingMonthlyActiveUsers: true featureTaglines: @@ -22221,16 +22181,16 @@ components: - featureTaglines yearlyCostUSD: 6.027456183070403 hasDebranding: true - flexPageLoadCostCents: 1.4894159098541704 - flexAdminUnit: 6.965117697638846 - maxWhiteLabeledTenants: 7.386281948385884 - flexSmallWidgetsCreditCostCents: 6.683562403749608 + flexPageLoadCostCents: 7.457744773683766 + flexAdminUnit: 2.8841621266687802 + maxWhiteLabeledTenants: 1.0246457001441578 + flexSmallWidgetsCreditCostCents: 9.018348186070783 tenantId: tenantId - flexCommentCostCents: 7.457744773683766 - flexModeratorCostCents: 9.018348186070783 - flexPageLoadUnit: 6.84685269835264 + flexCommentCostCents: 4.965218492984954 + flexModeratorCostCents: 3.5571952270680973 + flexPageLoadUnit: 1.1730742509559433 monthlyStripePlanId: monthlyStripePlanId - flexSSOAdminUnit: 0.8851374739011653 + flexSSOAdminUnit: 6.519180951018382 status: success properties: status: @@ -22242,7 +22202,6 @@ components: - tenantPackage type: object CreateTenantPackageBody: - additionalProperties: false example: maxMonthlySmallWidgetsCredits: 5.637376656633329 flexAPICreditCostCents: 9.965781217890562 @@ -22454,7 +22413,6 @@ components: - name type: object ReplaceTenantPackageBody: - additionalProperties: false example: flexAPICreditCostCents: 1.1730742509559433 flexMinimumCostCents: 6.438423552598547 @@ -22598,7 +22556,6 @@ components: - yearlyCostUSD type: object UpdateTenantPackageBody: - additionalProperties: false example: flexAPICreditCostCents: 1.1730742509559433 flexMinimumCostCents: 6.438423552598547 @@ -22729,7 +22686,6 @@ components: type: number type: object APITenantDailyUsage: - additionalProperties: false example: commentFetchCount: 5.962133916683182 ignored: true @@ -22826,7 +22782,6 @@ components: - yearNumber type: object GetTenantDailyUsagesResponse: - additionalProperties: false example: tenantDailyUsages: - commentFetchCount: 5.962133916683182 @@ -22880,7 +22835,6 @@ components: - tenantDailyUsages type: object MetaItem: - additionalProperties: false example: values: - values @@ -22898,7 +22852,6 @@ components: - values type: object QuestionResult: - additionalProperties: false example: createdAt: 2000-01-23T04:56:07.000+00:00 questionId: questionId @@ -22971,7 +22924,6 @@ components: - value type: object GetQuestionResultResponse: - additionalProperties: false example: questionResult: createdAt: 2000-01-23T04:56:07.000+00:00 @@ -23007,7 +22959,6 @@ components: - status type: object GetQuestionResultsResponse: - additionalProperties: false example: questionResults: - createdAt: 2000-01-23T04:56:07.000+00:00 @@ -23067,7 +23018,6 @@ components: - status type: object CreateQuestionResultResponse: - additionalProperties: false example: questionResult: createdAt: 2000-01-23T04:56:07.000+00:00 @@ -23209,7 +23159,6 @@ components: properties: {} type: object QuestionDatum: - additionalProperties: false example: total: 6 v: @@ -23236,7 +23185,6 @@ components: properties: {} type: object QuestionResultAggregationOverall: - additionalProperties: false example: average: 5.637376656633329 createdAt: 2000-01-23T04:56:07.000+00:00 @@ -23286,7 +23234,6 @@ components: - total type: object AggregateQuestionResultsResponse: - additionalProperties: false example: data: average: 5.637376656633329 @@ -23327,7 +23274,6 @@ components: properties: {} type: object BulkAggregateQuestionResultsResponse: - additionalProperties: false example: data: key: @@ -23361,7 +23307,6 @@ components: - status type: object BulkAggregateQuestionItem: - additionalProperties: false example: questionId: questionId timeBucket: day @@ -23391,7 +23336,6 @@ components: - aggId type: object BulkAggregateQuestionResultsRequest: - additionalProperties: false example: aggregations: - questionId: questionId @@ -23419,7 +23363,6 @@ components: - aggregations type: object CommentTranslation: - additionalProperties: false properties: comment: type: string @@ -23550,7 +23493,6 @@ components: - 15 type: integer CommentLogData: - additionalProperties: false example: votesDownAfter: 9.369310271410669 repeatAction: 6 @@ -23738,7 +23680,6 @@ components: type: boolean type: object CommentLogEntry: - additionalProperties: false example: d: 2000-01-23T04:56:07.000+00:00 t: 7 @@ -23811,7 +23752,6 @@ components: - t type: object FComment: - additionalProperties: false example: date: 2000-01-23T04:56:07.000+00:00 editKey: editKey @@ -24286,7 +24226,6 @@ components: - verified type: object FindCommentsByRangeItem: - additionalProperties: false example: result: createdAt: 2000-01-23T04:56:07.000+00:00 @@ -24324,7 +24263,6 @@ components: - result type: object FindCommentsByRangeResponse: - additionalProperties: false example: createdAt: 2000-01-23T04:56:07.000+00:00 results: @@ -24389,7 +24327,6 @@ components: - results type: object CombineQuestionResultsWithCommentsResponse: - additionalProperties: false example: data: createdAt: 2000-01-23T04:56:07.000+00:00 @@ -24464,7 +24401,6 @@ components: - excludes type: string SubQuestionCondition: - additionalProperties: false example: subQuestionId: subQuestionId value: 2.3021358869347655 @@ -24483,7 +24419,6 @@ components: - value type: object QuestionCondition: - additionalProperties: false description: |- A rule evaluated against a question's answer. value is the score for nps/slider/star/emoji/scale, 1 or 0 for thumbs, and the option index for choice/multi. @@ -24501,7 +24436,6 @@ components: - value type: object QuestionConfig: - additionalProperties: false example: commentBoxCondition: value: 7.061401241503109 @@ -24635,7 +24569,6 @@ components: - usedCount type: object GetQuestionConfigResponse: - additionalProperties: false example: status: success questionConfig: @@ -24687,7 +24620,6 @@ components: - status type: object GetQuestionConfigsResponse: - additionalProperties: false example: questionConfigs: - commentBoxCondition: @@ -24779,7 +24711,6 @@ components: - status type: object CreateQuestionConfigResponse: - additionalProperties: false example: status: success questionConfig: @@ -25005,7 +24936,6 @@ components: type: number type: object GetPollResponse: - additionalProperties: false example: poll: question: question @@ -25031,7 +24961,6 @@ components: - status type: object SavePollResponse: - additionalProperties: false example: poll: question: question @@ -25057,7 +24986,6 @@ components: - status type: object CommentPollOptionInput: - additionalProperties: false example: id: id label: label @@ -25071,7 +24999,6 @@ components: - label type: object CommentPollPutInput: - additionalProperties: false example: question: question options: @@ -25104,7 +25031,6 @@ components: - question type: object CommentPollPatch: - additionalProperties: false example: question: question options: @@ -25136,7 +25062,6 @@ components: type: boolean type: object PublicPollVote: - additionalProperties: false description: A single vote cast on a comment's poll. example: createdAt: 2000-01-23T04:56:07.000+00:00 @@ -25176,7 +25101,6 @@ components: - voterId type: object GetPollVotesResponse: - additionalProperties: false example: pollVotes: - createdAt: 2000-01-23T04:56:07.000+00:00 @@ -25208,7 +25132,6 @@ components: - status type: object GetPollVoteResponse: - additionalProperties: false example: pollVote: createdAt: 2000-01-23T04:56:07.000+00:00 @@ -25230,7 +25153,6 @@ components: - status type: object CreatePollVoteResponse: - additionalProperties: false example: pollVote: createdAt: 2000-01-23T04:56:07.000+00:00 @@ -25268,7 +25190,6 @@ components: - status type: object CreatePollVoteBody: - additionalProperties: false example: ip: ip commentId: commentId @@ -25291,7 +25212,6 @@ components: - optionId type: object DeletePollVoteResponse: - additionalProperties: false example: poll: question: question @@ -25317,7 +25237,6 @@ components: - status type: object PendingCommentToSyncOutbound: - additionalProperties: false example: lastError: "{}" webhookId: webhookId @@ -25599,7 +25518,6 @@ components: domain: type: string lastError: - additionalProperties: false type: object webhookId: type: string @@ -25617,7 +25535,6 @@ components: - type type: object GetPendingWebhookEventsResponse: - additionalProperties: false example: pendingWebhookEvents: - lastError: "{}" @@ -26133,7 +26050,6 @@ components: - status type: object GetPendingWebhookEventCountResponse: - additionalProperties: false example: count: 0.8008281904610115 status: success @@ -26148,7 +26064,6 @@ components: - status type: object GetNotificationsResponse: - additionalProperties: false example: notifications: - isUnreadMessage: true @@ -26224,7 +26139,6 @@ components: - status type: object GetNotificationCountResponse: - additionalProperties: false example: count: 0.8008281904610115 status: success @@ -26250,7 +26164,6 @@ components: type: boolean type: object UserNotificationCount: - additionalProperties: false example: createdAt: 2000-01-23T04:56:07.000+00:00 count: 0.8008281904610115 @@ -26275,7 +26188,6 @@ components: - expireAt type: object GetCachedNotificationCountResponse: - additionalProperties: false example: data: createdAt: 2000-01-23T04:56:07.000+00:00 @@ -26293,7 +26205,6 @@ components: - status type: object Moderator: - additionalProperties: false example: unFlaggedCount: 3.616076749251911 isEmailSuppressed: true @@ -26393,7 +26304,6 @@ components: - verificationId type: object GetModeratorResponse: - additionalProperties: false example: moderator: unFlaggedCount: 3.616076749251911 @@ -26428,7 +26338,6 @@ components: - status type: object GetModeratorsResponse: - additionalProperties: false example: status: success moderators: @@ -26486,7 +26395,6 @@ components: - status type: object CreateModeratorResponse: - additionalProperties: false example: moderator: unFlaggedCount: 3.616076749251911 @@ -26576,7 +26484,6 @@ components: - write type: string GetMeResponse: - additionalProperties: false example: tenantName: tenantName tenantId: tenantId @@ -26617,7 +26524,6 @@ components: - tenantName type: object TenantHashTag: - additionalProperties: false example: createdAt: 2000-01-23T04:56:07.000+00:00 tenantId: tenantId @@ -26643,7 +26549,6 @@ components: - tenantId type: object GetHashTagsResponse: - additionalProperties: false example: hashTags: - createdAt: 2000-01-23T04:56:07.000+00:00 @@ -26669,7 +26574,6 @@ components: - status type: object CreateHashTagResponse: - additionalProperties: false example: status: success hashTag: @@ -26688,7 +26592,6 @@ components: - status type: object CreateHashTagBody: - additionalProperties: false example: tenantId: tenantId tag: tag @@ -26704,7 +26607,6 @@ components: - tag type: object BulkCreateHashTagsResponse: - additionalProperties: false example: results: - status: success @@ -26734,7 +26636,6 @@ components: - status type: object BulkCreateHashTagsBody: - additionalProperties: false example: tenantId: tenantId tags: @@ -26753,7 +26654,6 @@ components: - tags type: object UpdateHashTagResponse: - additionalProperties: false example: status: success hashTag: @@ -26772,7 +26672,6 @@ components: - status type: object UpdateHashTagBody: - additionalProperties: false example: tenantId: tenantId tag: tag @@ -26786,7 +26685,6 @@ components: type: string type: object GetFeedPostsResponse: - additionalProperties: false example: feedPosts: - fromUserDisplayName: fromUserDisplayName @@ -26894,7 +26792,6 @@ components: - status type: object CreateFeedPostsResponse: - additionalProperties: false example: feedPost: fromUserDisplayName: fromUserDisplayName @@ -26965,7 +26862,6 @@ components: properties: {} type: object EmailTemplateDefinition: - additionalProperties: false example: emailTemplateId: emailTemplateId defaultTranslationsByLocale: @@ -26996,7 +26892,6 @@ components: - emailTemplateId type: object GetEmailTemplateDefinitionsResponse: - additionalProperties: false example: definitions: - emailTemplateId: emailTemplateId @@ -27024,7 +26919,6 @@ components: - status type: object EmailTemplateRenderErrorResponse: - additionalProperties: false example: createdAt: 2000-01-23T04:56:07.000+00:00 customTemplateId: customTemplateId @@ -27061,7 +26955,6 @@ components: - tenantId type: object GetEmailTemplateRenderErrorsResponse: - additionalProperties: false example: renderErrors: - createdAt: 2000-01-23T04:56:07.000+00:00 @@ -27091,7 +26984,6 @@ components: - status type: object CustomEmailTemplate: - additionalProperties: false example: createdAt: 2000-01-23T04:56:07.000+00:00 testData: "" @@ -27149,7 +27041,6 @@ components: - updatedByUserId type: object GetEmailTemplateResponse: - additionalProperties: false example: emailTemplate: createdAt: 2000-01-23T04:56:07.000+00:00 @@ -27175,7 +27066,6 @@ components: - status type: object GetEmailTemplatesResponse: - additionalProperties: false example: emailTemplates: - createdAt: 2000-01-23T04:56:07.000+00:00 @@ -27215,7 +27105,6 @@ components: - status type: object CreateEmailTemplateResponse: - additionalProperties: false example: emailTemplate: createdAt: 2000-01-23T04:56:07.000+00:00 @@ -27241,7 +27130,6 @@ components: - status type: object CreateEmailTemplateBody: - additionalProperties: false example: testData: key: "" @@ -27277,7 +27165,6 @@ components: - emailTemplateId type: object UpdateEmailTemplateBody: - additionalProperties: false example: testData: key: "" @@ -27309,7 +27196,6 @@ components: type: object type: object RenderEmailTemplateResponse: - additionalProperties: false example: html: html status: success @@ -27323,7 +27209,6 @@ components: - status type: object RenderEmailTemplateBody: - additionalProperties: false example: testData: key: "" @@ -27352,7 +27237,6 @@ components: - emailTemplateId type: object AddDomainConfigParams: - additionalProperties: false example: emailHeaders: {} emailFromName: emailFromName @@ -27385,7 +27269,6 @@ components: - domain type: object UpdateDomainConfigParams: - additionalProperties: false example: emailHeaders: {} emailFromName: emailFromName @@ -27418,7 +27301,6 @@ components: - domain type: object PatchDomainConfigParams: - additionalProperties: false example: emailHeaders: {} emailFromName: emailFromName @@ -27449,7 +27331,6 @@ components: type: object type: object APICommentBase: - additionalProperties: false properties: id: type: string @@ -27725,7 +27606,6 @@ components: votes: 5 isByAdmin: true APIGetCommentResponse: - additionalProperties: false example: comment: date: 9.301444243932576 @@ -27834,7 +27714,6 @@ components: - status type: object APIGetCommentsResponse: - additionalProperties: false example: comments: - date: 9.301444243932576 @@ -28040,7 +27919,6 @@ components: - status type: object UpdatableCommentParams: - additionalProperties: false example: date: 0.8008281904610115 externalParentId: externalParentId @@ -28201,7 +28079,6 @@ components: type: array type: object APISaveCommentResponse: - additionalProperties: false example: comment: date: 9.301444243932576 @@ -28323,7 +28200,6 @@ components: - user type: object CreateCommentParams: - additionalProperties: false example: date: 0 votesDown: 7 @@ -28440,7 +28316,6 @@ components: urlId: type: string meta: - additionalProperties: false type: object moderationGroupIds: items: @@ -28502,7 +28377,6 @@ components: - urlId type: object FlagCommentResponse: - additionalProperties: false example: reason: reason code: code @@ -28525,7 +28399,6 @@ components: - status type: object BlockFromCommentParams: - additionalProperties: false example: commentIdsToCheck: - commentIdsToCheck @@ -28537,7 +28410,6 @@ components: type: array type: object UnBlockFromCommentParams: - additionalProperties: false example: commentIdsToCheck: - commentIdsToCheck @@ -28549,7 +28421,6 @@ components: type: array type: object PageMigrationSuccess: - additionalProperties: false example: commentsMigrated: 5 from: from @@ -28576,7 +28447,6 @@ components: - type type: object PageMigrationFailure: - additionalProperties: false properties: from: type: string @@ -28599,7 +28469,6 @@ components: - type type: object PageMigrationUndoCounts: - additionalProperties: false example: notRestorable: 1 restored: 0 @@ -28803,7 +28672,6 @@ components: - status type: object APIAuditLog: - additionalProperties: false example: targetId: targetId ip: ip @@ -28877,7 +28745,6 @@ components: - resourceName type: object GetAuditLogsResponse: - additionalProperties: false example: auditLogs: - targetId: targetId @@ -28974,7 +28841,6 @@ components: example: groups: null AggregationResponse: - additionalProperties: false description: The API response returns the aggregated data along with simple stats example: @@ -28999,7 +28865,6 @@ components: - status type: object AggregationAPIError: - additionalProperties: false properties: status: $ref: "#/components/schemas/APIStatus" @@ -29017,7 +28882,6 @@ components: - status type: object QueryPredicate: - additionalProperties: false example: value: QueryPredicate_value key: key @@ -29052,7 +28916,6 @@ components: - count type: string AggregationOperation: - additionalProperties: false description: An operation that will be applied on a field example: op: sum @@ -29076,7 +28939,6 @@ components: - op type: object AggregationRequest: - additionalProperties: false description: "The aggregation request accepts a resource, optional grouping\ \ keys, an array of operations, and an optional sort" example: @@ -29125,7 +28987,6 @@ components: - resourceName type: object CreateAgentTenantResponse: - additionalProperties: false example: apiBaseUrl: apiBaseUrl mcpUrl: mcpUrl @@ -29166,7 +29027,6 @@ components: - tenantId type: object CreateAgentTenantBody: - additionalProperties: false example: agent: agent name: name diff --git a/client/build.gradle b/client/build.gradle index 2eaff380..7991403b 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'java' apply plugin: 'com.diffplug.spotless' group = 'com.fastcomments' -version = '3.1.1' +version = '3.1.2' buildscript { repositories { diff --git a/client/build.sbt b/client/build.sbt index 154c40b1..427ecc66 100644 --- a/client/build.sbt +++ b/client/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "com.fastcomments", name := "client", - version := "3.1.1", + version := "3.1.2", scalaVersion := "2.11.12", scalacOptions ++= Seq("-feature"), compile / javacOptions ++= Seq("-Xlint:deprecation"), diff --git a/client/docs/CustomConfigParameters.md b/client/docs/CustomConfigParameters.md index c9127c9e..1de958f5 100644 --- a/client/docs/CustomConfigParameters.md +++ b/client/docs/CustomConfigParameters.md @@ -13,7 +13,9 @@ |**allowAnonFlag** | **Boolean** | | [optional] | |**allowAnonVotes** | **Boolean** | | [optional] | |**allowedLanguages** | **List<String>** | | [optional] | +|**allowSimpleSSOAdmins** | **Boolean** | Simple SSO users on this page or domain can be admins and moderators: they keep those flags and pick them up from a matching email. | [optional] | |**autoGenerateUsername** | **Boolean** | Serve each new visitor a unique generated username as the prefilled defaultUsername. | [optional] | +|**autoVerifySimpleSSOComments** | **Boolean** | Comments from Simple SSO users on this page or domain are verified right away, instead of through an emailed link. | [optional] | |**collapseReplies** | **Boolean** | | [optional] | |**commentCountFormat** | **String** | | [optional] | |**commentHTMLRenderingMode** | **CommentHTMLRenderingMode** | | [optional] | diff --git a/client/docs/TenantPackage.md b/client/docs/TenantPackage.md index 1be73f07..0e470cc8 100644 --- a/client/docs/TenantPackage.md +++ b/client/docs/TenantPackage.md @@ -12,8 +12,11 @@ |**tenantId** | **String** | | | |**createdAt** | **OffsetDateTime** | | | |**templateId** | **String** | | [optional] | -|**monthlyCostUSD** | **Double** | | | +|**monthlyCostUSD** | **Double** | Always the USD list price, also on regionally priced tenants (commissions and plan comparisons read it). | | |**yearlyCostUSD** | **Double** | | | +|**pricingCurrency** | **String** | Regional prices the tenant is charged, when pricingCurrency is set; the Stripe plan ids below are then in that currency. | [optional] | +|**monthlyCostLocal** | **Double** | | [optional] | +|**yearlyCostLocal** | **Double** | | [optional] | |**monthlyStripePlanId** | **String** | | | |**yearlyStripePlanId** | **String** | | | |**maxMonthlyPageLoads** | **Double** | | | diff --git a/client/docs/WebhookComment.md b/client/docs/WebhookComment.md index 4167cc22..7d174398 100644 --- a/client/docs/WebhookComment.md +++ b/client/docs/WebhookComment.md @@ -36,6 +36,7 @@ |**mentions** | [**List<CommentUserMentionInfo>**](CommentUserMentionInfo.md) | | | |**domain** | **String** | | | |**moderationGroupIds** | **List<String>** | | | +|**badges** | [**List<CommentUserBadgeInfo>**](CommentUserBadgeInfo.md) | | | diff --git a/client/pom.xml b/client/pom.xml index e479ab49..73a5500f 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ client jar client - 3.1.1 + 3.1.2 https://fastcomments.com FastComments API Client - A SDK for interacting with the FastComments API diff --git a/client/src/main/java/com/fastcomments/invoker/ApiClient.java b/client/src/main/java/com/fastcomments/invoker/ApiClient.java index df796152..a04c05b7 100644 --- a/client/src/main/java/com/fastcomments/invoker/ApiClient.java +++ b/client/src/main/java/com/fastcomments/invoker/ApiClient.java @@ -147,7 +147,7 @@ protected void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("OpenAPI-Generator/3.1.1/java"); + setUserAgent("OpenAPI-Generator/3.1.2/java"); authentications = new HashMap(); } diff --git a/client/src/main/java/com/fastcomments/invoker/Configuration.java b/client/src/main/java/com/fastcomments/invoker/Configuration.java index 2b2d9951..46a78996 100644 --- a/client/src/main/java/com/fastcomments/invoker/Configuration.java +++ b/client/src/main/java/com/fastcomments/invoker/Configuration.java @@ -19,7 +19,7 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.23.0-SNAPSHOT") public class Configuration { - public static final String VERSION = "3.1.1"; + public static final String VERSION = "3.1.2"; private static final AtomicReference defaultApiClient = new AtomicReference<>(); private static volatile Supplier apiClientFactory = ApiClient::new; diff --git a/client/src/main/java/com/fastcomments/model/APIAuditLog.java b/client/src/main/java/com/fastcomments/model/APIAuditLog.java index 769e272e..1796a1c4 100644 --- a/client/src/main/java/com/fastcomments/model/APIAuditLog.java +++ b/client/src/main/java/com/fastcomments/model/APIAuditLog.java @@ -559,6 +559,50 @@ public void setsIdHashed(@javax.annotation.Nullable String sIdHashed) { this.sIdHashed = sIdHashed; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIAuditLog instance itself + */ + public APIAuditLog putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -585,12 +629,13 @@ public boolean equals(Object o) { Objects.equals(this.targetId, apIAuditLog.targetId) && Objects.equals(this.targetLabel, apIAuditLog.targetLabel) && Objects.equals(this.ua, apIAuditLog.ua) && - Objects.equals(this.sIdHashed, apIAuditLog.sIdHashed); + Objects.equals(this.sIdHashed, apIAuditLog.sIdHashed)&& + Objects.equals(this.additionalProperties, apIAuditLog.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, userId, username, resourceName, crudType, from, url, ip, when, description, serverStartDate, objectDetails, targetId, targetLabel, ua, sIdHashed); + return Objects.hash(id, userId, username, resourceName, crudType, from, url, ip, when, description, serverStartDate, objectDetails, targetId, targetLabel, ua, sIdHashed, additionalProperties); } @Override @@ -613,6 +658,7 @@ public String toString() { sb.append(" targetLabel: ").append(toIndentedString(targetLabel)).append("\n"); sb.append(" ua: ").append(toIndentedString(ua)).append("\n"); sb.append(" sIdHashed: ").append(toIndentedString(sIdHashed)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -650,14 +696,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIAuditLog.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIAuditLog` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIAuditLog.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -727,6 +765,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIAuditLog value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -734,7 +794,28 @@ public void write(JsonWriter out, APIAuditLog value) throws IOException { public APIAuditLog read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIAuditLog instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APIBanUserChangeLog.java b/client/src/main/java/com/fastcomments/model/APIBanUserChangeLog.java index 3685225f..481e0dff 100644 --- a/client/src/main/java/com/fastcomments/model/APIBanUserChangeLog.java +++ b/client/src/main/java/com/fastcomments/model/APIBanUserChangeLog.java @@ -160,6 +160,50 @@ public void setChangedValuesBefore(@javax.annotation.Nullable APIBanUserChangedV this.changedValuesBefore = changedValuesBefore; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIBanUserChangeLog instance itself + */ + public APIBanUserChangeLog putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -174,12 +218,13 @@ public boolean equals(Object o) { return Objects.equals(this.createdBannedUserId, apIBanUserChangeLog.createdBannedUserId) && Objects.equals(this.updatedBannedUserId, apIBanUserChangeLog.updatedBannedUserId) && Objects.equals(this.deletedBannedUsers, apIBanUserChangeLog.deletedBannedUsers) && - Objects.equals(this.changedValuesBefore, apIBanUserChangeLog.changedValuesBefore); + Objects.equals(this.changedValuesBefore, apIBanUserChangeLog.changedValuesBefore)&& + Objects.equals(this.additionalProperties, apIBanUserChangeLog.additionalProperties); } @Override public int hashCode() { - return Objects.hash(createdBannedUserId, updatedBannedUserId, deletedBannedUsers, changedValuesBefore); + return Objects.hash(createdBannedUserId, updatedBannedUserId, deletedBannedUsers, changedValuesBefore, additionalProperties); } @Override @@ -190,6 +235,7 @@ public String toString() { sb.append(" updatedBannedUserId: ").append(toIndentedString(updatedBannedUserId)).append("\n"); sb.append(" deletedBannedUsers: ").append(toIndentedString(deletedBannedUsers)).append("\n"); sb.append(" changedValuesBefore: ").append(toIndentedString(changedValuesBefore)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -226,14 +272,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in APIBanUserChangeLog is not found in the empty JSON string", APIBanUserChangeLog.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIBanUserChangeLog.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIBanUserChangeLog` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("createdBannedUserId") != null && !jsonObj.get("createdBannedUserId").isJsonNull()) && !jsonObj.get("createdBannedUserId").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `createdBannedUserId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("createdBannedUserId").toString())); @@ -276,6 +314,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIBanUserChangeLog value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -283,7 +343,28 @@ public void write(JsonWriter out, APIBanUserChangeLog value) throws IOException public APIBanUserChangeLog read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIBanUserChangeLog instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APIBanUserChangedValues.java b/client/src/main/java/com/fastcomments/model/APIBanUserChangedValues.java index aee9500e..7172b347 100644 --- a/client/src/main/java/com/fastcomments/model/APIBanUserChangedValues.java +++ b/client/src/main/java/com/fastcomments/model/APIBanUserChangedValues.java @@ -365,6 +365,50 @@ public void setBanReason(@javax.annotation.Nullable String banReason) { this.banReason = banReason; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIBanUserChangedValues instance itself + */ + public APIBanUserChangedValues putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -388,12 +432,13 @@ public boolean equals(Object o) { Objects.equals(this.banType, apIBanUserChangedValues.banType) && Objects.equals(this.bannedUntil, apIBanUserChangedValues.bannedUntil) && Objects.equals(this.hasEmailWildcard, apIBanUserChangedValues.hasEmailWildcard) && - Objects.equals(this.banReason, apIBanUserChangedValues.banReason); + Objects.equals(this.banReason, apIBanUserChangedValues.banReason)&& + Objects.equals(this.additionalProperties, apIBanUserChangedValues.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, userId, email, username, ipHash, createdAt, bannedByUserId, bannedCommentText, banType, bannedUntil, hasEmailWildcard, banReason); + return Objects.hash(id, tenantId, userId, email, username, ipHash, createdAt, bannedByUserId, bannedCommentText, banType, bannedUntil, hasEmailWildcard, banReason, additionalProperties); } @Override @@ -413,6 +458,7 @@ public String toString() { sb.append(" bannedUntil: ").append(toIndentedString(bannedUntil)).append("\n"); sb.append(" hasEmailWildcard: ").append(toIndentedString(hasEmailWildcard)).append("\n"); sb.append(" banReason: ").append(toIndentedString(banReason)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -449,14 +495,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in APIBanUserChangedValues is not found in the empty JSON string", APIBanUserChangedValues.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIBanUserChangedValues.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIBanUserChangedValues` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("_id") != null && !jsonObj.get("_id").isJsonNull()) && !jsonObj.get("_id").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("_id").toString())); @@ -505,6 +543,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIBanUserChangedValues value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -512,7 +572,28 @@ public void write(JsonWriter out, APIBanUserChangedValues value) throws IOExcept public APIBanUserChangedValues read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIBanUserChangedValues instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APIBannedUser.java b/client/src/main/java/com/fastcomments/model/APIBannedUser.java index faad2cd6..3d72ec78 100644 --- a/client/src/main/java/com/fastcomments/model/APIBannedUser.java +++ b/client/src/main/java/com/fastcomments/model/APIBannedUser.java @@ -365,6 +365,50 @@ public void setBanReason(@javax.annotation.Nullable String banReason) { this.banReason = banReason; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIBannedUser instance itself + */ + public APIBannedUser putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -388,12 +432,13 @@ public boolean equals(Object o) { Objects.equals(this.banType, apIBannedUser.banType) && Objects.equals(this.bannedUntil, apIBannedUser.bannedUntil) && Objects.equals(this.hasEmailWildcard, apIBannedUser.hasEmailWildcard) && - Objects.equals(this.banReason, apIBannedUser.banReason); + Objects.equals(this.banReason, apIBannedUser.banReason)&& + Objects.equals(this.additionalProperties, apIBannedUser.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, userId, email, username, ipHash, createdAt, bannedByUserId, bannedCommentText, banType, bannedUntil, hasEmailWildcard, banReason); + return Objects.hash(id, tenantId, userId, email, username, ipHash, createdAt, bannedByUserId, bannedCommentText, banType, bannedUntil, hasEmailWildcard, banReason, additionalProperties); } @Override @@ -413,6 +458,7 @@ public String toString() { sb.append(" bannedUntil: ").append(toIndentedString(bannedUntil)).append("\n"); sb.append(" hasEmailWildcard: ").append(toIndentedString(hasEmailWildcard)).append("\n"); sb.append(" banReason: ").append(toIndentedString(banReason)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -450,14 +496,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIBannedUser.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIBannedUser` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIBannedUser.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -512,6 +550,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIBannedUser value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -519,7 +579,28 @@ public void write(JsonWriter out, APIBannedUser value) throws IOException { public APIBannedUser read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIBannedUser instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APICommentBase.java b/client/src/main/java/com/fastcomments/model/APICommentBase.java index 14a9d3ee..46810160 100644 --- a/client/src/main/java/com/fastcomments/model/APICommentBase.java +++ b/client/src/main/java/com/fastcomments/model/APICommentBase.java @@ -1371,6 +1371,50 @@ public void setVotesUp(@javax.annotation.Nullable Integer votesUp) { this.votesUp = votesUp; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APICommentBase instance itself + */ + public APICommentBase putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -1434,12 +1478,13 @@ public boolean equals(Object o) { Objects.equals(this.verifiedDate, apICommentBase.verifiedDate) && Objects.equals(this.votes, apICommentBase.votes) && Objects.equals(this.votesDown, apICommentBase.votesDown) && - Objects.equals(this.votesUp, apICommentBase.votesUp); + Objects.equals(this.votesUp, apICommentBase.votesUp)&& + Objects.equals(this.additionalProperties, apICommentBase.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, aiDeterminedSpam, anonUserId, approved, avatarSrc, badges, comment, commentHTML, commenterEmail, commenterLink, commenterName, date, displayLabel, domain, externalId, externalParentId, expireAt, feedbackIds, flagCount, fromProductId, hasCode, hasImages, hasLinks, hashTags, isByAdmin, isByModerator, isDeleted, isDeletedUser, isPinned, isLocked, isSpam, localDateHours, localDateString, locale, mentions, meta, moderationGroupIds, notificationSentForParent, notificationSentForParentTenant, pageTitle, parentId, rating, reviewed, tenantId, url, urlId, urlIdRaw, userId, verified, verifiedDate, votes, votesDown, votesUp); + return Objects.hash(id, aiDeterminedSpam, anonUserId, approved, avatarSrc, badges, comment, commentHTML, commenterEmail, commenterLink, commenterName, date, displayLabel, domain, externalId, externalParentId, expireAt, feedbackIds, flagCount, fromProductId, hasCode, hasImages, hasLinks, hashTags, isByAdmin, isByModerator, isDeleted, isDeletedUser, isPinned, isLocked, isSpam, localDateHours, localDateString, locale, mentions, meta, moderationGroupIds, notificationSentForParent, notificationSentForParentTenant, pageTitle, parentId, rating, reviewed, tenantId, url, urlId, urlIdRaw, userId, verified, verifiedDate, votes, votesDown, votesUp, additionalProperties); } @Override @@ -1499,6 +1544,7 @@ public String toString() { sb.append(" votes: ").append(toIndentedString(votes)).append("\n"); sb.append(" votesDown: ").append(toIndentedString(votesDown)).append("\n"); sb.append(" votesUp: ").append(toIndentedString(votesUp)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -1536,14 +1582,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APICommentBase.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APICommentBase` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APICommentBase.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -1681,6 +1719,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APICommentBase value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -1688,7 +1748,28 @@ public void write(JsonWriter out, APICommentBase value) throws IOException { public APICommentBase read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APICommentBase instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APICommentCommonBannedUser.java b/client/src/main/java/com/fastcomments/model/APICommentCommonBannedUser.java index 0b11dc35..f41beb26 100644 --- a/client/src/main/java/com/fastcomments/model/APICommentCommonBannedUser.java +++ b/client/src/main/java/com/fastcomments/model/APICommentCommonBannedUser.java @@ -245,6 +245,50 @@ public void setBanReason(@javax.annotation.Nullable String banReason) { this.banReason = banReason; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APICommentCommonBannedUser instance itself + */ + public APICommentCommonBannedUser putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -263,12 +307,13 @@ public boolean equals(Object o) { Objects.equals(this.ipHash, apICommentCommonBannedUser.ipHash) && Objects.equals(this.bannedUntil, apICommentCommonBannedUser.bannedUntil) && Objects.equals(this.hasEmailWildcard, apICommentCommonBannedUser.hasEmailWildcard) && - Objects.equals(this.banReason, apICommentCommonBannedUser.banReason); + Objects.equals(this.banReason, apICommentCommonBannedUser.banReason)&& + Objects.equals(this.additionalProperties, apICommentCommonBannedUser.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, userId, banType, email, ipHash, bannedUntil, hasEmailWildcard, banReason); + return Objects.hash(id, userId, banType, email, ipHash, bannedUntil, hasEmailWildcard, banReason, additionalProperties); } @Override @@ -283,6 +328,7 @@ public String toString() { sb.append(" bannedUntil: ").append(toIndentedString(bannedUntil)).append("\n"); sb.append(" hasEmailWildcard: ").append(toIndentedString(hasEmailWildcard)).append("\n"); sb.append(" banReason: ").append(toIndentedString(banReason)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -320,14 +366,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APICommentCommonBannedUser.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APICommentCommonBannedUser` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APICommentCommonBannedUser.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -370,6 +408,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APICommentCommonBannedUser value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -377,7 +437,28 @@ public void write(JsonWriter out, APICommentCommonBannedUser value) throws IOExc public APICommentCommonBannedUser read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APICommentCommonBannedUser instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APICreateUserBadgeResponse.java b/client/src/main/java/com/fastcomments/model/APICreateUserBadgeResponse.java index cb2bcf15..ccc82be1 100644 --- a/client/src/main/java/com/fastcomments/model/APICreateUserBadgeResponse.java +++ b/client/src/main/java/com/fastcomments/model/APICreateUserBadgeResponse.java @@ -136,6 +136,50 @@ public void setNotes(@javax.annotation.Nullable List notes) { this.notes = notes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APICreateUserBadgeResponse instance itself + */ + public APICreateUserBadgeResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -149,12 +193,13 @@ public boolean equals(Object o) { APICreateUserBadgeResponse apICreateUserBadgeResponse = (APICreateUserBadgeResponse) o; return Objects.equals(this.status, apICreateUserBadgeResponse.status) && Objects.equals(this.userBadge, apICreateUserBadgeResponse.userBadge) && - Objects.equals(this.notes, apICreateUserBadgeResponse.notes); + Objects.equals(this.notes, apICreateUserBadgeResponse.notes)&& + Objects.equals(this.additionalProperties, apICreateUserBadgeResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, userBadge, notes); + return Objects.hash(status, userBadge, notes, additionalProperties); } @Override @@ -164,6 +209,7 @@ public String toString() { sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" userBadge: ").append(toIndentedString(userBadge)).append("\n"); sb.append(" notes: ").append(toIndentedString(notes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -201,14 +247,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APICreateUserBadgeResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APICreateUserBadgeResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APICreateUserBadgeResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -241,6 +279,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APICreateUserBadgeResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -248,7 +308,28 @@ public void write(JsonWriter out, APICreateUserBadgeResponse value) throws IOExc public APICreateUserBadgeResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APICreateUserBadgeResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APIDomainConfiguration.java b/client/src/main/java/com/fastcomments/model/APIDomainConfiguration.java index 4697b7e9..f3d7227a 100644 --- a/client/src/main/java/com/fastcomments/model/APIDomainConfiguration.java +++ b/client/src/main/java/com/fastcomments/model/APIDomainConfiguration.java @@ -424,6 +424,50 @@ public void setDisableUnsubscribeLinks(@javax.annotation.Nullable Boolean disabl this.disableUnsubscribeLinks = disableUnsubscribeLinks; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIDomainConfiguration instance itself + */ + public APIDomainConfiguration putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -449,12 +493,13 @@ public boolean equals(Object o) { Objects.equals(this.logoSrc, apIDomainConfiguration.logoSrc) && Objects.equals(this.logoSrc100px, apIDomainConfiguration.logoSrc100px) && Objects.equals(this.footerUnsubscribeURL, apIDomainConfiguration.footerUnsubscribeURL) && - Objects.equals(this.disableUnsubscribeLinks, apIDomainConfiguration.disableUnsubscribeLinks); + Objects.equals(this.disableUnsubscribeLinks, apIDomainConfiguration.disableUnsubscribeLinks)&& + Objects.equals(this.additionalProperties, apIDomainConfiguration.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, domain, emailFromName, emailFromEmail, emailHeaders, wpSyncToken, wpSynced, wpURL, createdAt, autoAddedDate, siteType, logoSrc, logoSrc100px, footerUnsubscribeURL, disableUnsubscribeLinks); + return Objects.hash(id, domain, emailFromName, emailFromEmail, emailHeaders, wpSyncToken, wpSynced, wpURL, createdAt, autoAddedDate, siteType, logoSrc, logoSrc100px, footerUnsubscribeURL, disableUnsubscribeLinks, additionalProperties); } @Override @@ -476,6 +521,7 @@ public String toString() { sb.append(" logoSrc100px: ").append(toIndentedString(logoSrc100px)).append("\n"); sb.append(" footerUnsubscribeURL: ").append(toIndentedString(footerUnsubscribeURL)).append("\n"); sb.append(" disableUnsubscribeLinks: ").append(toIndentedString(disableUnsubscribeLinks)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -513,14 +559,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIDomainConfiguration.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIDomainConfiguration` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIDomainConfiguration.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -576,6 +614,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIDomainConfiguration value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -583,7 +643,28 @@ public void write(JsonWriter out, APIDomainConfiguration value) throws IOExcepti public APIDomainConfiguration read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIDomainConfiguration instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APIEmptySuccessResponse.java b/client/src/main/java/com/fastcomments/model/APIEmptySuccessResponse.java index 9ae398dc..3c23c783 100644 --- a/client/src/main/java/com/fastcomments/model/APIEmptySuccessResponse.java +++ b/client/src/main/java/com/fastcomments/model/APIEmptySuccessResponse.java @@ -77,6 +77,50 @@ public void setStatus(@javax.annotation.Nonnull APIStatus status) { this.status = status; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIEmptySuccessResponse instance itself + */ + public APIEmptySuccessResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } APIEmptySuccessResponse apIEmptySuccessResponse = (APIEmptySuccessResponse) o; - return Objects.equals(this.status, apIEmptySuccessResponse.status); + return Objects.equals(this.status, apIEmptySuccessResponse.status)&& + Objects.equals(this.additionalProperties, apIEmptySuccessResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status); + return Objects.hash(status, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class APIEmptySuccessResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -138,14 +184,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIEmptySuccessResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIEmptySuccessResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIEmptySuccessResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -172,6 +210,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIEmptySuccessResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -179,7 +239,28 @@ public void write(JsonWriter out, APIEmptySuccessResponse value) throws IOExcept public APIEmptySuccessResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIEmptySuccessResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APIError.java b/client/src/main/java/com/fastcomments/model/APIError.java index 47af126c..cf3d581f 100644 --- a/client/src/main/java/com/fastcomments/model/APIError.java +++ b/client/src/main/java/com/fastcomments/model/APIError.java @@ -246,6 +246,50 @@ public void setCustomConfig(@javax.annotation.Nullable CustomConfigParameters cu this.customConfig = customConfig; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIError instance itself + */ + public APIError putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -264,12 +308,13 @@ public boolean equals(Object o) { Objects.equals(this.bannedUntil, apIError.bannedUntil) && Objects.equals(this.maxCharacterLength, apIError.maxCharacterLength) && Objects.equals(this.translatedError, apIError.translatedError) && - Objects.equals(this.customConfig, apIError.customConfig); + Objects.equals(this.customConfig, apIError.customConfig)&& + Objects.equals(this.additionalProperties, apIError.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, reason, code, secondaryCode, bannedUntil, maxCharacterLength, translatedError, customConfig); + return Objects.hash(status, reason, code, secondaryCode, bannedUntil, maxCharacterLength, translatedError, customConfig, additionalProperties); } @Override @@ -284,6 +329,7 @@ public String toString() { sb.append(" maxCharacterLength: ").append(toIndentedString(maxCharacterLength)).append("\n"); sb.append(" translatedError: ").append(toIndentedString(translatedError)).append("\n"); sb.append(" customConfig: ").append(toIndentedString(customConfig)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -321,14 +367,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIError.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIError` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIError.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -371,6 +409,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIError value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -378,7 +438,28 @@ public void write(JsonWriter out, APIError value) throws IOException { public APIError read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIError instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APIGetCommentResponse.java b/client/src/main/java/com/fastcomments/model/APIGetCommentResponse.java index d1cf0515..908635ce 100644 --- a/client/src/main/java/com/fastcomments/model/APIGetCommentResponse.java +++ b/client/src/main/java/com/fastcomments/model/APIGetCommentResponse.java @@ -102,6 +102,50 @@ public void setComment(@javax.annotation.Nonnull APIComment comment) { this.comment = comment; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIGetCommentResponse instance itself + */ + public APIGetCommentResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } APIGetCommentResponse apIGetCommentResponse = (APIGetCommentResponse) o; return Objects.equals(this.status, apIGetCommentResponse.status) && - Objects.equals(this.comment, apIGetCommentResponse.comment); + Objects.equals(this.comment, apIGetCommentResponse.comment)&& + Objects.equals(this.additionalProperties, apIGetCommentResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, comment); + return Objects.hash(status, comment, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class APIGetCommentResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIGetCommentResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIGetCommentResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIGetCommentResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIGetCommentResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, APIGetCommentResponse value) throws IOExceptio public APIGetCommentResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIGetCommentResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APIGetCommentsResponse.java b/client/src/main/java/com/fastcomments/model/APIGetCommentsResponse.java index de2856c1..7360d4d3 100644 --- a/client/src/main/java/com/fastcomments/model/APIGetCommentsResponse.java +++ b/client/src/main/java/com/fastcomments/model/APIGetCommentsResponse.java @@ -112,6 +112,50 @@ public void setComments(@javax.annotation.Nonnull List comments) { this.comments = comments; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIGetCommentsResponse instance itself + */ + public APIGetCommentsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } APIGetCommentsResponse apIGetCommentsResponse = (APIGetCommentsResponse) o; return Objects.equals(this.status, apIGetCommentsResponse.status) && - Objects.equals(this.comments, apIGetCommentsResponse.comments); + Objects.equals(this.comments, apIGetCommentsResponse.comments)&& + Objects.equals(this.additionalProperties, apIGetCommentsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, comments); + return Objects.hash(status, comments, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class APIGetCommentsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" comments: ").append(toIndentedString(comments)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIGetCommentsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIGetCommentsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIGetCommentsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIGetCommentsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, APIGetCommentsResponse value) throws IOExcepti public APIGetCommentsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIGetCommentsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APIGetUserBadgeProgressListResponse.java b/client/src/main/java/com/fastcomments/model/APIGetUserBadgeProgressListResponse.java index b4047103..2da13764 100644 --- a/client/src/main/java/com/fastcomments/model/APIGetUserBadgeProgressListResponse.java +++ b/client/src/main/java/com/fastcomments/model/APIGetUserBadgeProgressListResponse.java @@ -112,6 +112,50 @@ public void setUserBadgeProgresses(@javax.annotation.Nonnull List additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIGetUserBadgeProgressListResponse instance itself + */ + public APIGetUserBadgeProgressListResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } APIGetUserBadgeProgressListResponse apIGetUserBadgeProgressListResponse = (APIGetUserBadgeProgressListResponse) o; return Objects.equals(this.status, apIGetUserBadgeProgressListResponse.status) && - Objects.equals(this.userBadgeProgresses, apIGetUserBadgeProgressListResponse.userBadgeProgresses); + Objects.equals(this.userBadgeProgresses, apIGetUserBadgeProgressListResponse.userBadgeProgresses)&& + Objects.equals(this.additionalProperties, apIGetUserBadgeProgressListResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, userBadgeProgresses); + return Objects.hash(status, userBadgeProgresses, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class APIGetUserBadgeProgressListResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" userBadgeProgresses: ").append(toIndentedString(userBadgeProgresses)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIGetUserBadgeProgressListResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIGetUserBadgeProgressListResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIGetUserBadgeProgressListResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIGetUserBadgeProgressListResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, APIGetUserBadgeProgressListResponse value) thr public APIGetUserBadgeProgressListResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIGetUserBadgeProgressListResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APIGetUserBadgeProgressResponse.java b/client/src/main/java/com/fastcomments/model/APIGetUserBadgeProgressResponse.java index 0461c6a7..3961d646 100644 --- a/client/src/main/java/com/fastcomments/model/APIGetUserBadgeProgressResponse.java +++ b/client/src/main/java/com/fastcomments/model/APIGetUserBadgeProgressResponse.java @@ -102,6 +102,50 @@ public void setUserBadgeProgress(@javax.annotation.Nonnull UserBadgeProgress use this.userBadgeProgress = userBadgeProgress; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIGetUserBadgeProgressResponse instance itself + */ + public APIGetUserBadgeProgressResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } APIGetUserBadgeProgressResponse apIGetUserBadgeProgressResponse = (APIGetUserBadgeProgressResponse) o; return Objects.equals(this.status, apIGetUserBadgeProgressResponse.status) && - Objects.equals(this.userBadgeProgress, apIGetUserBadgeProgressResponse.userBadgeProgress); + Objects.equals(this.userBadgeProgress, apIGetUserBadgeProgressResponse.userBadgeProgress)&& + Objects.equals(this.additionalProperties, apIGetUserBadgeProgressResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, userBadgeProgress); + return Objects.hash(status, userBadgeProgress, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class APIGetUserBadgeProgressResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" userBadgeProgress: ").append(toIndentedString(userBadgeProgress)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIGetUserBadgeProgressResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIGetUserBadgeProgressResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIGetUserBadgeProgressResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIGetUserBadgeProgressResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, APIGetUserBadgeProgressResponse value) throws public APIGetUserBadgeProgressResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIGetUserBadgeProgressResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APIGetUserBadgeResponse.java b/client/src/main/java/com/fastcomments/model/APIGetUserBadgeResponse.java index 0cfd99cc..45c8d7f4 100644 --- a/client/src/main/java/com/fastcomments/model/APIGetUserBadgeResponse.java +++ b/client/src/main/java/com/fastcomments/model/APIGetUserBadgeResponse.java @@ -102,6 +102,50 @@ public void setUserBadge(@javax.annotation.Nonnull UserBadge userBadge) { this.userBadge = userBadge; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIGetUserBadgeResponse instance itself + */ + public APIGetUserBadgeResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } APIGetUserBadgeResponse apIGetUserBadgeResponse = (APIGetUserBadgeResponse) o; return Objects.equals(this.status, apIGetUserBadgeResponse.status) && - Objects.equals(this.userBadge, apIGetUserBadgeResponse.userBadge); + Objects.equals(this.userBadge, apIGetUserBadgeResponse.userBadge)&& + Objects.equals(this.additionalProperties, apIGetUserBadgeResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, userBadge); + return Objects.hash(status, userBadge, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class APIGetUserBadgeResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" userBadge: ").append(toIndentedString(userBadge)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIGetUserBadgeResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIGetUserBadgeResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIGetUserBadgeResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIGetUserBadgeResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, APIGetUserBadgeResponse value) throws IOExcept public APIGetUserBadgeResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIGetUserBadgeResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APIGetUserBadgesResponse.java b/client/src/main/java/com/fastcomments/model/APIGetUserBadgesResponse.java index 147d69b5..915f067c 100644 --- a/client/src/main/java/com/fastcomments/model/APIGetUserBadgesResponse.java +++ b/client/src/main/java/com/fastcomments/model/APIGetUserBadgesResponse.java @@ -112,6 +112,50 @@ public void setUserBadges(@javax.annotation.Nonnull List userBadges) this.userBadges = userBadges; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIGetUserBadgesResponse instance itself + */ + public APIGetUserBadgesResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } APIGetUserBadgesResponse apIGetUserBadgesResponse = (APIGetUserBadgesResponse) o; return Objects.equals(this.status, apIGetUserBadgesResponse.status) && - Objects.equals(this.userBadges, apIGetUserBadgesResponse.userBadges); + Objects.equals(this.userBadges, apIGetUserBadgesResponse.userBadges)&& + Objects.equals(this.additionalProperties, apIGetUserBadgesResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, userBadges); + return Objects.hash(status, userBadges, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class APIGetUserBadgesResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" userBadges: ").append(toIndentedString(userBadges)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIGetUserBadgesResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIGetUserBadgesResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIGetUserBadgesResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIGetUserBadgesResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, APIGetUserBadgesResponse value) throws IOExcep public APIGetUserBadgesResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIGetUserBadgesResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APIModerateUserBanPreferences.java b/client/src/main/java/com/fastcomments/model/APIModerateUserBanPreferences.java index 94bdb80f..216a2200 100644 --- a/client/src/main/java/com/fastcomments/model/APIModerateUserBanPreferences.java +++ b/client/src/main/java/com/fastcomments/model/APIModerateUserBanPreferences.java @@ -148,6 +148,50 @@ public void setLastBanDuration(@javax.annotation.Nonnull String lastBanDuration) this.lastBanDuration = lastBanDuration; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APIModerateUserBanPreferences instance itself + */ + public APIModerateUserBanPreferences putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -162,12 +206,13 @@ public boolean equals(Object o) { return Objects.equals(this.shouldBanEmail, apIModerateUserBanPreferences.shouldBanEmail) && Objects.equals(this.shouldBanByIP, apIModerateUserBanPreferences.shouldBanByIP) && Objects.equals(this.lastBanType, apIModerateUserBanPreferences.lastBanType) && - Objects.equals(this.lastBanDuration, apIModerateUserBanPreferences.lastBanDuration); + Objects.equals(this.lastBanDuration, apIModerateUserBanPreferences.lastBanDuration)&& + Objects.equals(this.additionalProperties, apIModerateUserBanPreferences.additionalProperties); } @Override public int hashCode() { - return Objects.hash(shouldBanEmail, shouldBanByIP, lastBanType, lastBanDuration); + return Objects.hash(shouldBanEmail, shouldBanByIP, lastBanType, lastBanDuration, additionalProperties); } @Override @@ -178,6 +223,7 @@ public String toString() { sb.append(" shouldBanByIP: ").append(toIndentedString(shouldBanByIP)).append("\n"); sb.append(" lastBanType: ").append(toIndentedString(lastBanType)).append("\n"); sb.append(" lastBanDuration: ").append(toIndentedString(lastBanDuration)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -215,14 +261,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APIModerateUserBanPreferences.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APIModerateUserBanPreferences` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APIModerateUserBanPreferences.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -253,6 +291,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APIModerateUserBanPreferences value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -260,7 +320,28 @@ public void write(JsonWriter out, APIModerateUserBanPreferences value) throws IO public APIModerateUserBanPreferences read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APIModerateUserBanPreferences instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APISSOUser.java b/client/src/main/java/com/fastcomments/model/APISSOUser.java index dcdb61ed..79d7b926 100644 --- a/client/src/main/java/com/fastcomments/model/APISSOUser.java +++ b/client/src/main/java/com/fastcomments/model/APISSOUser.java @@ -542,6 +542,50 @@ public void setGroupIds(@javax.annotation.Nullable List groupIds) { this.groupIds = groupIds; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APISSOUser instance itself + */ + public APISSOUser putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -572,12 +616,13 @@ public boolean equals(Object o) { Objects.equals(this.isProfileCommentsPrivate, apISSOUser.isProfileCommentsPrivate) && Objects.equals(this.isProfileDMDisabled, apISSOUser.isProfileDMDisabled) && Objects.equals(this.hasBlockedUsers, apISSOUser.hasBlockedUsers) && - Objects.equals(this.groupIds, apISSOUser.groupIds); + Objects.equals(this.groupIds, apISSOUser.groupIds)&& + Objects.equals(this.additionalProperties, apISSOUser.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, username, websiteUrl, email, signUpDate, createdFromUrlId, loginCount, avatarSrc, optedInNotifications, optedInSubscriptionNotifications, displayLabel, displayName, isAccountOwner, isAdminAdmin, isCommentModeratorAdmin, isProfileActivityPrivate, isProfileCommentsPrivate, isProfileDMDisabled, hasBlockedUsers, groupIds); + return Objects.hash(id, username, websiteUrl, email, signUpDate, createdFromUrlId, loginCount, avatarSrc, optedInNotifications, optedInSubscriptionNotifications, displayLabel, displayName, isAccountOwner, isAdminAdmin, isCommentModeratorAdmin, isProfileActivityPrivate, isProfileCommentsPrivate, isProfileDMDisabled, hasBlockedUsers, groupIds, additionalProperties); } @Override @@ -604,6 +649,7 @@ public String toString() { sb.append(" isProfileDMDisabled: ").append(toIndentedString(isProfileDMDisabled)).append("\n"); sb.append(" hasBlockedUsers: ").append(toIndentedString(hasBlockedUsers)).append("\n"); sb.append(" groupIds: ").append(toIndentedString(groupIds)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -641,14 +687,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APISSOUser.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APISSOUser` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APISSOUser.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -701,6 +739,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APISSOUser value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -708,7 +768,28 @@ public void write(JsonWriter out, APISSOUser value) throws IOException { public APISSOUser read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APISSOUser instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APISaveCommentResponse.java b/client/src/main/java/com/fastcomments/model/APISaveCommentResponse.java index 2713014d..faaf9a2e 100644 --- a/client/src/main/java/com/fastcomments/model/APISaveCommentResponse.java +++ b/client/src/main/java/com/fastcomments/model/APISaveCommentResponse.java @@ -161,6 +161,50 @@ public void setModuleData(@javax.annotation.Nullable Map moduleD this.moduleData = moduleData; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APISaveCommentResponse instance itself + */ + public APISaveCommentResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -175,12 +219,13 @@ public boolean equals(Object o) { return Objects.equals(this.status, apISaveCommentResponse.status) && Objects.equals(this.comment, apISaveCommentResponse.comment) && Objects.equals(this.user, apISaveCommentResponse.user) && - Objects.equals(this.moduleData, apISaveCommentResponse.moduleData); + Objects.equals(this.moduleData, apISaveCommentResponse.moduleData)&& + Objects.equals(this.additionalProperties, apISaveCommentResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, comment, user, moduleData); + return Objects.hash(status, comment, user, moduleData, additionalProperties); } @Override @@ -191,6 +236,7 @@ public String toString() { sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); sb.append(" user: ").append(toIndentedString(user)).append("\n"); sb.append(" moduleData: ").append(toIndentedString(moduleData)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -228,14 +274,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APISaveCommentResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APISaveCommentResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APISaveCommentResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -268,6 +306,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APISaveCommentResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -275,7 +335,28 @@ public void write(JsonWriter out, APISaveCommentResponse value) throws IOExcepti public APISaveCommentResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APISaveCommentResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APITenant.java b/client/src/main/java/com/fastcomments/model/APITenant.java index f609f6c0..74eec8cf 100644 --- a/client/src/main/java/com/fastcomments/model/APITenant.java +++ b/client/src/main/java/com/fastcomments/model/APITenant.java @@ -771,6 +771,50 @@ public void setMeta(@javax.annotation.Nullable Map meta) { this.meta = meta; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APITenant instance itself + */ + public APITenant putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -810,12 +854,13 @@ public boolean equals(Object o) { Objects.equals(this.hasDebranding, apITenant.hasDebranding) && Objects.equals(this.flexLastBilledAmount, apITenant.flexLastBilledAmount) && Objects.equals(this.deAnonIpAddr, apITenant.deAnonIpAddr) && - Objects.equals(this.meta, apITenant.meta); + Objects.equals(this.meta, apITenant.meta)&& + Objects.equals(this.additionalProperties, apITenant.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, name, email, signUpDate, packageId, paymentFrequency, billingInfoValid, billingHandledExternally, createdBy, isSetup, domainConfiguration, billingInfo, stripeCustomerId, stripeSubscriptionId, stripePlanId, enableProfanityFilter, enableSpamFilter, lastBillingIssueReminderDate, removeUnverifiedComments, unverifiedCommentsTTLms, commentsRequireApproval, autoApproveCommentOnVerification, sendProfaneToSpam, hasFlexPricing, hasAuditing, hasDebranding, flexLastBilledAmount, deAnonIpAddr, meta); + return Objects.hash(id, name, email, signUpDate, packageId, paymentFrequency, billingInfoValid, billingHandledExternally, createdBy, isSetup, domainConfiguration, billingInfo, stripeCustomerId, stripeSubscriptionId, stripePlanId, enableProfanityFilter, enableSpamFilter, lastBillingIssueReminderDate, removeUnverifiedComments, unverifiedCommentsTTLms, commentsRequireApproval, autoApproveCommentOnVerification, sendProfaneToSpam, hasFlexPricing, hasAuditing, hasDebranding, flexLastBilledAmount, deAnonIpAddr, meta, additionalProperties); } @Override @@ -851,6 +896,7 @@ public String toString() { sb.append(" flexLastBilledAmount: ").append(toIndentedString(flexLastBilledAmount)).append("\n"); sb.append(" deAnonIpAddr: ").append(toIndentedString(deAnonIpAddr)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -888,14 +934,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APITenant.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APITenant` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APITenant.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -958,6 +996,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APITenant value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -965,7 +1025,28 @@ public void write(JsonWriter out, APITenant value) throws IOException { public APITenant read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APITenant instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APITenantDailyUsage.java b/client/src/main/java/com/fastcomments/model/APITenantDailyUsage.java index 4cbd92ee..f7ab1c20 100644 --- a/client/src/main/java/com/fastcomments/model/APITenantDailyUsage.java +++ b/client/src/main/java/com/fastcomments/model/APITenantDailyUsage.java @@ -509,6 +509,50 @@ public void setApiErrorCount(@javax.annotation.Nonnull Double apiErrorCount) { this.apiErrorCount = apiErrorCount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APITenantDailyUsage instance itself + */ + public APITenantDailyUsage putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -538,12 +582,13 @@ public boolean equals(Object o) { Objects.equals(this.createdAt, apITenantDailyUsage.createdAt) && Objects.equals(this.billed, apITenantDailyUsage.billed) && Objects.equals(this.ignored, apITenantDailyUsage.ignored) && - Objects.equals(this.apiErrorCount, apITenantDailyUsage.apiErrorCount); + Objects.equals(this.apiErrorCount, apITenantDailyUsage.apiErrorCount)&& + Objects.equals(this.additionalProperties, apITenantDailyUsage.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, yearNumber, monthNumber, dayNumber, commentFetchCount, commentCreateCount, conversationCreateCount, voteCount, accountCreatedCount, userMentionSearch, hashTagSearch, gifSearchTrending, gifSearch, apiCreditsUsed, createdAt, billed, ignored, apiErrorCount); + return Objects.hash(id, tenantId, yearNumber, monthNumber, dayNumber, commentFetchCount, commentCreateCount, conversationCreateCount, voteCount, accountCreatedCount, userMentionSearch, hashTagSearch, gifSearchTrending, gifSearch, apiCreditsUsed, createdAt, billed, ignored, apiErrorCount, additionalProperties); } @Override @@ -569,6 +614,7 @@ public String toString() { sb.append(" billed: ").append(toIndentedString(billed)).append("\n"); sb.append(" ignored: ").append(toIndentedString(ignored)).append("\n"); sb.append(" apiErrorCount: ").append(toIndentedString(apiErrorCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -606,14 +652,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APITenantDailyUsage.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APITenantDailyUsage` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APITenantDailyUsage.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -644,6 +682,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APITenantDailyUsage value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -651,7 +711,28 @@ public void write(JsonWriter out, APITenantDailyUsage value) throws IOException public APITenantDailyUsage read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APITenantDailyUsage instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APITicket.java b/client/src/main/java/com/fastcomments/model/APITicket.java index 5d04e6f1..1ad3d102 100644 --- a/client/src/main/java/com/fastcomments/model/APITicket.java +++ b/client/src/main/java/com/fastcomments/model/APITicket.java @@ -278,6 +278,50 @@ public void setFileCount(@javax.annotation.Nonnull Integer fileCount) { this.fileCount = fileCount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APITicket instance itself + */ + public APITicket putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -297,12 +341,13 @@ public boolean equals(Object o) { Objects.equals(this.subject, apITicket.subject) && Objects.equals(this.createdAt, apITicket.createdAt) && Objects.equals(this.state, apITicket.state) && - Objects.equals(this.fileCount, apITicket.fileCount); + Objects.equals(this.fileCount, apITicket.fileCount)&& + Objects.equals(this.additionalProperties, apITicket.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, urlId, userId, managedByTenantId, assignedUserIds, subject, createdAt, state, fileCount); + return Objects.hash(id, urlId, userId, managedByTenantId, assignedUserIds, subject, createdAt, state, fileCount, additionalProperties); } @Override @@ -318,6 +363,7 @@ public String toString() { sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); sb.append(" state: ").append(toIndentedString(state)).append("\n"); sb.append(" fileCount: ").append(toIndentedString(fileCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -355,14 +401,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APITicket.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APITicket` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APITicket.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -411,6 +449,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APITicket value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -418,7 +478,28 @@ public void write(JsonWriter out, APITicket value) throws IOException { public APITicket read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APITicket instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APITicketDetail.java b/client/src/main/java/com/fastcomments/model/APITicketDetail.java index cd1f8a42..885b2723 100644 --- a/client/src/main/java/com/fastcomments/model/APITicketDetail.java +++ b/client/src/main/java/com/fastcomments/model/APITicketDetail.java @@ -383,6 +383,50 @@ public void setAckAt(@javax.annotation.Nullable String ackAt) { this.ackAt = ackAt; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APITicketDetail instance itself + */ + public APITicketDetail putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -406,12 +450,13 @@ public boolean equals(Object o) { Objects.equals(this.files, apITicketDetail.files) && Objects.equals(this.reopenedAt, apITicketDetail.reopenedAt) && Objects.equals(this.resolvedAt, apITicketDetail.resolvedAt) && - Objects.equals(this.ackAt, apITicketDetail.ackAt); + Objects.equals(this.ackAt, apITicketDetail.ackAt)&& + Objects.equals(this.additionalProperties, apITicketDetail.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, urlId, userId, managedByTenantId, assignedUserIds, subject, createdAt, state, fileCount, files, reopenedAt, resolvedAt, ackAt); + return Objects.hash(id, urlId, userId, managedByTenantId, assignedUserIds, subject, createdAt, state, fileCount, files, reopenedAt, resolvedAt, ackAt, additionalProperties); } @Override @@ -431,6 +476,7 @@ public String toString() { sb.append(" reopenedAt: ").append(toIndentedString(reopenedAt)).append("\n"); sb.append(" resolvedAt: ").append(toIndentedString(resolvedAt)).append("\n"); sb.append(" ackAt: ").append(toIndentedString(ackAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -468,14 +514,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APITicketDetail.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APITicketDetail` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APITicketDetail.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -543,6 +581,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APITicketDetail value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -550,7 +610,28 @@ public void write(JsonWriter out, APITicketDetail value) throws IOException { public APITicketDetail read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APITicketDetail instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/APITicketFile.java b/client/src/main/java/com/fastcomments/model/APITicketFile.java index 1d32b094..dfc71ea7 100644 --- a/client/src/main/java/com/fastcomments/model/APITicketFile.java +++ b/client/src/main/java/com/fastcomments/model/APITicketFile.java @@ -292,6 +292,50 @@ public void setExpired(@javax.annotation.Nullable Boolean expired) { this.expired = expired; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the APITicketFile instance itself + */ + public APITicketFile putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -312,12 +356,13 @@ public boolean equals(Object o) { Objects.equals(this.uploadedAt, apITicketFile.uploadedAt) && Objects.equals(this.url, apITicketFile.url) && Objects.equals(this.expiresAt, apITicketFile.expiresAt) && - Objects.equals(this.expired, apITicketFile.expired); + Objects.equals(this.expired, apITicketFile.expired)&& + Objects.equals(this.additionalProperties, apITicketFile.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, s3Key, originalFileName, sizeBytes, contentType, uploadedByUserId, uploadedAt, url, expiresAt, expired); + return Objects.hash(id, s3Key, originalFileName, sizeBytes, contentType, uploadedByUserId, uploadedAt, url, expiresAt, expired, additionalProperties); } @Override @@ -334,6 +379,7 @@ public String toString() { sb.append(" url: ").append(toIndentedString(url)).append("\n"); sb.append(" expiresAt: ").append(toIndentedString(expiresAt)).append("\n"); sb.append(" expired: ").append(toIndentedString(expired)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -371,14 +417,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!APITicketFile.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `APITicketFile` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : APITicketFile.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -427,6 +465,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, APITicketFile value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -434,7 +494,28 @@ public void write(JsonWriter out, APITicketFile value) throws IOException { public APITicketFile read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + APITicketFile instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/AddDomainConfigParams.java b/client/src/main/java/com/fastcomments/model/AddDomainConfigParams.java index fa8df43b..61bca531 100644 --- a/client/src/main/java/com/fastcomments/model/AddDomainConfigParams.java +++ b/client/src/main/java/com/fastcomments/model/AddDomainConfigParams.java @@ -230,6 +230,50 @@ public void setEmailHeaders(@javax.annotation.Nullable Map email this.emailHeaders = emailHeaders; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AddDomainConfigParams instance itself + */ + public AddDomainConfigParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -247,12 +291,13 @@ public boolean equals(Object o) { Objects.equals(this.logoSrc, addDomainConfigParams.logoSrc) && Objects.equals(this.logoSrc100px, addDomainConfigParams.logoSrc100px) && Objects.equals(this.footerUnsubscribeURL, addDomainConfigParams.footerUnsubscribeURL) && - Objects.equals(this.emailHeaders, addDomainConfigParams.emailHeaders); + Objects.equals(this.emailHeaders, addDomainConfigParams.emailHeaders)&& + Objects.equals(this.additionalProperties, addDomainConfigParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(domain, emailFromName, emailFromEmail, logoSrc, logoSrc100px, footerUnsubscribeURL, emailHeaders); + return Objects.hash(domain, emailFromName, emailFromEmail, logoSrc, logoSrc100px, footerUnsubscribeURL, emailHeaders, additionalProperties); } @Override @@ -266,6 +311,7 @@ public String toString() { sb.append(" logoSrc100px: ").append(toIndentedString(logoSrc100px)).append("\n"); sb.append(" footerUnsubscribeURL: ").append(toIndentedString(footerUnsubscribeURL)).append("\n"); sb.append(" emailHeaders: ").append(toIndentedString(emailHeaders)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -303,14 +349,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AddDomainConfigParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AddDomainConfigParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AddDomainConfigParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -353,6 +391,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AddDomainConfigParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -360,7 +420,28 @@ public void write(JsonWriter out, AddDomainConfigParams value) throws IOExceptio public AddDomainConfigParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AddDomainConfigParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/AdjustCommentVotesParams.java b/client/src/main/java/com/fastcomments/model/AdjustCommentVotesParams.java index d395f4fb..46bd9253 100644 --- a/client/src/main/java/com/fastcomments/model/AdjustCommentVotesParams.java +++ b/client/src/main/java/com/fastcomments/model/AdjustCommentVotesParams.java @@ -76,6 +76,50 @@ public void setAdjustVoteAmount(@javax.annotation.Nonnull Double adjustVoteAmoun this.adjustVoteAmount = adjustVoteAmount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdjustCommentVotesParams instance itself + */ + public AdjustCommentVotesParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -87,12 +131,13 @@ public boolean equals(Object o) { return false; } AdjustCommentVotesParams adjustCommentVotesParams = (AdjustCommentVotesParams) o; - return Objects.equals(this.adjustVoteAmount, adjustCommentVotesParams.adjustVoteAmount); + return Objects.equals(this.adjustVoteAmount, adjustCommentVotesParams.adjustVoteAmount)&& + Objects.equals(this.additionalProperties, adjustCommentVotesParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(adjustVoteAmount); + return Objects.hash(adjustVoteAmount, additionalProperties); } @Override @@ -100,6 +145,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AdjustCommentVotesParams {\n"); sb.append(" adjustVoteAmount: ").append(toIndentedString(adjustVoteAmount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -137,14 +183,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AdjustCommentVotesParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AdjustCommentVotesParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AdjustCommentVotesParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -169,6 +207,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AdjustCommentVotesParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -176,7 +236,28 @@ public void write(JsonWriter out, AdjustCommentVotesParams value) throws IOExcep public AdjustCommentVotesParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdjustCommentVotesParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/AdjustVotesResponse.java b/client/src/main/java/com/fastcomments/model/AdjustVotesResponse.java index ccd28e08..815f94b3 100644 --- a/client/src/main/java/com/fastcomments/model/AdjustVotesResponse.java +++ b/client/src/main/java/com/fastcomments/model/AdjustVotesResponse.java @@ -100,6 +100,50 @@ public void setNewCommentVotes(@javax.annotation.Nonnull Integer newCommentVotes this.newCommentVotes = newCommentVotes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdjustVotesResponse instance itself + */ + public AdjustVotesResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -112,12 +156,13 @@ public boolean equals(Object o) { } AdjustVotesResponse adjustVotesResponse = (AdjustVotesResponse) o; return Objects.equals(this.status, adjustVotesResponse.status) && - Objects.equals(this.newCommentVotes, adjustVotesResponse.newCommentVotes); + Objects.equals(this.newCommentVotes, adjustVotesResponse.newCommentVotes)&& + Objects.equals(this.additionalProperties, adjustVotesResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, newCommentVotes); + return Objects.hash(status, newCommentVotes, additionalProperties); } @Override @@ -126,6 +171,7 @@ public String toString() { sb.append("class AdjustVotesResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" newCommentVotes: ").append(toIndentedString(newCommentVotes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -163,14 +209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AdjustVotesResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AdjustVotesResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AdjustVotesResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -198,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AdjustVotesResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,7 +265,28 @@ public void write(JsonWriter out, AdjustVotesResponse value) throws IOException public AdjustVotesResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdjustVotesResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/AggregateQuestionResultsResponse.java b/client/src/main/java/com/fastcomments/model/AggregateQuestionResultsResponse.java index f2e1a7a0..ea81e2f4 100644 --- a/client/src/main/java/com/fastcomments/model/AggregateQuestionResultsResponse.java +++ b/client/src/main/java/com/fastcomments/model/AggregateQuestionResultsResponse.java @@ -102,6 +102,50 @@ public void setData(@javax.annotation.Nonnull QuestionResultAggregationOverall d this.data = data; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AggregateQuestionResultsResponse instance itself + */ + public AggregateQuestionResultsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } AggregateQuestionResultsResponse aggregateQuestionResultsResponse = (AggregateQuestionResultsResponse) o; return Objects.equals(this.status, aggregateQuestionResultsResponse.status) && - Objects.equals(this.data, aggregateQuestionResultsResponse.data); + Objects.equals(this.data, aggregateQuestionResultsResponse.data)&& + Objects.equals(this.additionalProperties, aggregateQuestionResultsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, data); + return Objects.hash(status, data, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class AggregateQuestionResultsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AggregateQuestionResultsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AggregateQuestionResultsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AggregateQuestionResultsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AggregateQuestionResultsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, AggregateQuestionResultsResponse value) throws public AggregateQuestionResultsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AggregateQuestionResultsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/AggregationAPIError.java b/client/src/main/java/com/fastcomments/model/AggregationAPIError.java index 69a46b3b..6cb1b634 100644 --- a/client/src/main/java/com/fastcomments/model/AggregationAPIError.java +++ b/client/src/main/java/com/fastcomments/model/AggregationAPIError.java @@ -159,6 +159,50 @@ public void setValidResourceNames(@javax.annotation.Nullable List validR this.validResourceNames = validResourceNames; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AggregationAPIError instance itself + */ + public AggregationAPIError putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -173,12 +217,13 @@ public boolean equals(Object o) { return Objects.equals(this.status, aggregationAPIError.status) && Objects.equals(this.reason, aggregationAPIError.reason) && Objects.equals(this.code, aggregationAPIError.code) && - Objects.equals(this.validResourceNames, aggregationAPIError.validResourceNames); + Objects.equals(this.validResourceNames, aggregationAPIError.validResourceNames)&& + Objects.equals(this.additionalProperties, aggregationAPIError.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, reason, code, validResourceNames); + return Objects.hash(status, reason, code, validResourceNames, additionalProperties); } @Override @@ -189,6 +234,7 @@ public String toString() { sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); sb.append(" code: ").append(toIndentedString(code)).append("\n"); sb.append(" validResourceNames: ").append(toIndentedString(validResourceNames)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -226,14 +272,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AggregationAPIError.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AggregationAPIError` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AggregationAPIError.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -270,6 +308,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AggregationAPIError value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -277,7 +337,28 @@ public void write(JsonWriter out, AggregationAPIError value) throws IOException public AggregationAPIError read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AggregationAPIError instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/AggregationOperation.java b/client/src/main/java/com/fastcomments/model/AggregationOperation.java index ab20e4e5..e4c4f45d 100644 --- a/client/src/main/java/com/fastcomments/model/AggregationOperation.java +++ b/client/src/main/java/com/fastcomments/model/AggregationOperation.java @@ -149,6 +149,50 @@ public void setExpandArray(@javax.annotation.Nullable Boolean expandArray) { this.expandArray = expandArray; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AggregationOperation instance itself + */ + public AggregationOperation putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -163,12 +207,13 @@ public boolean equals(Object o) { return Objects.equals(this.field, aggregationOperation.field) && Objects.equals(this.op, aggregationOperation.op) && Objects.equals(this.alias, aggregationOperation.alias) && - Objects.equals(this.expandArray, aggregationOperation.expandArray); + Objects.equals(this.expandArray, aggregationOperation.expandArray)&& + Objects.equals(this.additionalProperties, aggregationOperation.additionalProperties); } @Override public int hashCode() { - return Objects.hash(field, op, alias, expandArray); + return Objects.hash(field, op, alias, expandArray, additionalProperties); } @Override @@ -179,6 +224,7 @@ public String toString() { sb.append(" op: ").append(toIndentedString(op)).append("\n"); sb.append(" alias: ").append(toIndentedString(alias)).append("\n"); sb.append(" expandArray: ").append(toIndentedString(expandArray)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -216,14 +262,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AggregationOperation.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AggregationOperation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AggregationOperation.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -256,6 +294,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AggregationOperation value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -263,7 +323,28 @@ public void write(JsonWriter out, AggregationOperation value) throws IOException public AggregationOperation read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AggregationOperation instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/AggregationRequest.java b/client/src/main/java/com/fastcomments/model/AggregationRequest.java index 560a0607..defdf2f8 100644 --- a/client/src/main/java/com/fastcomments/model/AggregationRequest.java +++ b/client/src/main/java/com/fastcomments/model/AggregationRequest.java @@ -201,6 +201,50 @@ public void setSort(@javax.annotation.Nullable AggregationRequestSort sort) { this.sort = sort; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AggregationRequest instance itself + */ + public AggregationRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -216,12 +260,13 @@ public boolean equals(Object o) { Objects.equals(this.resourceName, aggregationRequest.resourceName) && Objects.equals(this.groupBy, aggregationRequest.groupBy) && Objects.equals(this.operations, aggregationRequest.operations) && - Objects.equals(this.sort, aggregationRequest.sort); + Objects.equals(this.sort, aggregationRequest.sort)&& + Objects.equals(this.additionalProperties, aggregationRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(query, resourceName, groupBy, operations, sort); + return Objects.hash(query, resourceName, groupBy, operations, sort, additionalProperties); } @Override @@ -233,6 +278,7 @@ public String toString() { sb.append(" groupBy: ").append(toIndentedString(groupBy)).append("\n"); sb.append(" operations: ").append(toIndentedString(operations)).append("\n"); sb.append(" sort: ").append(toIndentedString(sort)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -270,14 +316,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AggregationRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AggregationRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AggregationRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -337,6 +375,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AggregationRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -344,7 +404,28 @@ public void write(JsonWriter out, AggregationRequest value) throws IOException { public AggregationRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AggregationRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/AggregationResponse.java b/client/src/main/java/com/fastcomments/model/AggregationResponse.java index 0c738003..e39435ac 100644 --- a/client/src/main/java/com/fastcomments/model/AggregationResponse.java +++ b/client/src/main/java/com/fastcomments/model/AggregationResponse.java @@ -137,6 +137,50 @@ public void setStats(@javax.annotation.Nullable AggregationResponseStats stats) this.stats = stats; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AggregationResponse instance itself + */ + public AggregationResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -150,12 +194,13 @@ public boolean equals(Object o) { AggregationResponse aggregationResponse = (AggregationResponse) o; return Objects.equals(this.status, aggregationResponse.status) && Objects.equals(this.data, aggregationResponse.data) && - Objects.equals(this.stats, aggregationResponse.stats); + Objects.equals(this.stats, aggregationResponse.stats)&& + Objects.equals(this.additionalProperties, aggregationResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, data, stats); + return Objects.hash(status, data, stats, additionalProperties); } @Override @@ -165,6 +210,7 @@ public String toString() { sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); sb.append(" stats: ").append(toIndentedString(stats)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -202,14 +248,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AggregationResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AggregationResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AggregationResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -250,6 +288,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AggregationResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -257,7 +317,28 @@ public void write(JsonWriter out, AggregationResponse value) throws IOException public AggregationResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AggregationResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BanUserFromCommentResult.java b/client/src/main/java/com/fastcomments/model/BanUserFromCommentResult.java index cb879af0..e3158170 100644 --- a/client/src/main/java/com/fastcomments/model/BanUserFromCommentResult.java +++ b/client/src/main/java/com/fastcomments/model/BanUserFromCommentResult.java @@ -149,6 +149,50 @@ public void setReason(@javax.annotation.Nullable String reason) { this.reason = reason; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BanUserFromCommentResult instance itself + */ + public BanUserFromCommentResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -163,12 +207,13 @@ public boolean equals(Object o) { return Objects.equals(this.status, banUserFromCommentResult.status) && Objects.equals(this.changelog, banUserFromCommentResult.changelog) && Objects.equals(this.code, banUserFromCommentResult.code) && - Objects.equals(this.reason, banUserFromCommentResult.reason); + Objects.equals(this.reason, banUserFromCommentResult.reason)&& + Objects.equals(this.additionalProperties, banUserFromCommentResult.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, changelog, code, reason); + return Objects.hash(status, changelog, code, reason, additionalProperties); } @Override @@ -179,6 +224,7 @@ public String toString() { sb.append(" changelog: ").append(toIndentedString(changelog)).append("\n"); sb.append(" code: ").append(toIndentedString(code)).append("\n"); sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -216,14 +262,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BanUserFromCommentResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BanUserFromCommentResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BanUserFromCommentResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -261,6 +299,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BanUserFromCommentResult value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -268,7 +328,28 @@ public void write(JsonWriter out, BanUserFromCommentResult value) throws IOExcep public BanUserFromCommentResult read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BanUserFromCommentResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BanUserUndoParams.java b/client/src/main/java/com/fastcomments/model/BanUserUndoParams.java index ae040e0c..60e3d34f 100644 --- a/client/src/main/java/com/fastcomments/model/BanUserUndoParams.java +++ b/client/src/main/java/com/fastcomments/model/BanUserUndoParams.java @@ -77,6 +77,50 @@ public void setChangelog(@javax.annotation.Nonnull APIBanUserChangeLog changelog this.changelog = changelog; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BanUserUndoParams instance itself + */ + public BanUserUndoParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } BanUserUndoParams banUserUndoParams = (BanUserUndoParams) o; - return Objects.equals(this.changelog, banUserUndoParams.changelog); + return Objects.equals(this.changelog, banUserUndoParams.changelog)&& + Objects.equals(this.additionalProperties, banUserUndoParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(changelog); + return Objects.hash(changelog, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BanUserUndoParams {\n"); sb.append(" changelog: ").append(toIndentedString(changelog)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -138,14 +184,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BanUserUndoParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BanUserUndoParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BanUserUndoParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -172,6 +210,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BanUserUndoParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -179,7 +239,28 @@ public void write(JsonWriter out, BanUserUndoParams value) throws IOException { public BanUserUndoParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BanUserUndoParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BannedUserMatch.java b/client/src/main/java/com/fastcomments/model/BannedUserMatch.java index 7d5abcec..1be7f91a 100644 --- a/client/src/main/java/com/fastcomments/model/BannedUserMatch.java +++ b/client/src/main/java/com/fastcomments/model/BannedUserMatch.java @@ -102,6 +102,50 @@ public void setMatchedOnValue(@javax.annotation.Nullable BannedUserMatchMatchedO this.matchedOnValue = matchedOnValue; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BannedUserMatch instance itself + */ + public BannedUserMatch putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } BannedUserMatch bannedUserMatch = (BannedUserMatch) o; return Objects.equals(this.matchedOn, bannedUserMatch.matchedOn) && - Objects.equals(this.matchedOnValue, bannedUserMatch.matchedOnValue); + Objects.equals(this.matchedOnValue, bannedUserMatch.matchedOnValue)&& + Objects.equals(this.additionalProperties, bannedUserMatch.additionalProperties); } @Override public int hashCode() { - return Objects.hash(matchedOn, matchedOnValue); + return Objects.hash(matchedOn, matchedOnValue, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class BannedUserMatch {\n"); sb.append(" matchedOn: ").append(toIndentedString(matchedOn)).append("\n"); sb.append(" matchedOnValue: ").append(toIndentedString(matchedOnValue)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BannedUserMatch.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BannedUserMatch` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BannedUserMatch.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -203,6 +241,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BannedUserMatch value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -210,7 +270,28 @@ public void write(JsonWriter out, BannedUserMatch value) throws IOException { public BannedUserMatch read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BannedUserMatch instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BillingInfo.java b/client/src/main/java/com/fastcomments/model/BillingInfo.java index 7556978e..2a368a93 100644 --- a/client/src/main/java/com/fastcomments/model/BillingInfo.java +++ b/client/src/main/java/com/fastcomments/model/BillingInfo.java @@ -268,6 +268,50 @@ public void setVatId(@javax.annotation.Nullable String vatId) { this.vatId = vatId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BillingInfo instance itself + */ + public BillingInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -287,12 +331,13 @@ public boolean equals(Object o) { Objects.equals(this.country, billingInfo.country) && Objects.equals(this.currency, billingInfo.currency) && Objects.equals(this.email, billingInfo.email) && - Objects.equals(this.vatId, billingInfo.vatId); + Objects.equals(this.vatId, billingInfo.vatId)&& + Objects.equals(this.additionalProperties, billingInfo.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, address, city, state, zip, country, currency, email, vatId); + return Objects.hash(name, address, city, state, zip, country, currency, email, vatId, additionalProperties); } @Override @@ -308,6 +353,7 @@ public String toString() { sb.append(" currency: ").append(toIndentedString(currency)).append("\n"); sb.append(" email: ").append(toIndentedString(email)).append("\n"); sb.append(" vatId: ").append(toIndentedString(vatId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -345,14 +391,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BillingInfo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BillingInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BillingInfo.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -404,6 +442,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BillingInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -411,7 +471,28 @@ public void write(JsonWriter out, BillingInfo value) throws IOException { public BillingInfo read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BillingInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BlockFromCommentParams.java b/client/src/main/java/com/fastcomments/model/BlockFromCommentParams.java index 69fbd6d3..c1357362 100644 --- a/client/src/main/java/com/fastcomments/model/BlockFromCommentParams.java +++ b/client/src/main/java/com/fastcomments/model/BlockFromCommentParams.java @@ -86,6 +86,50 @@ public void setCommentIdsToCheck(@javax.annotation.Nullable List comment this.commentIdsToCheck = commentIdsToCheck; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BlockFromCommentParams instance itself + */ + public BlockFromCommentParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } BlockFromCommentParams blockFromCommentParams = (BlockFromCommentParams) o; - return Objects.equals(this.commentIdsToCheck, blockFromCommentParams.commentIdsToCheck); + return Objects.equals(this.commentIdsToCheck, blockFromCommentParams.commentIdsToCheck)&& + Objects.equals(this.additionalProperties, blockFromCommentParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(commentIdsToCheck); + return Objects.hash(commentIdsToCheck, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BlockFromCommentParams {\n"); sb.append(" commentIdsToCheck: ").append(toIndentedString(commentIdsToCheck)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -146,14 +192,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in BlockFromCommentParams is not found in the empty JSON string", BlockFromCommentParams.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BlockFromCommentParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BlockFromCommentParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("commentIdsToCheck") != null && !jsonObj.get("commentIdsToCheck").isJsonNull() && !jsonObj.get("commentIdsToCheck").isJsonArray()) { @@ -176,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BlockFromCommentParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -183,7 +243,28 @@ public void write(JsonWriter out, BlockFromCommentParams value) throws IOExcepti public BlockFromCommentParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BlockFromCommentParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BlockSuccess.java b/client/src/main/java/com/fastcomments/model/BlockSuccess.java index 65957dad..6b5fe969 100644 --- a/client/src/main/java/com/fastcomments/model/BlockSuccess.java +++ b/client/src/main/java/com/fastcomments/model/BlockSuccess.java @@ -111,6 +111,50 @@ public void setCommentStatuses(@javax.annotation.Nonnull Map co this.commentStatuses = commentStatuses; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BlockSuccess instance itself + */ + public BlockSuccess putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -123,12 +167,13 @@ public boolean equals(Object o) { } BlockSuccess blockSuccess = (BlockSuccess) o; return Objects.equals(this.status, blockSuccess.status) && - Objects.equals(this.commentStatuses, blockSuccess.commentStatuses); + Objects.equals(this.commentStatuses, blockSuccess.commentStatuses)&& + Objects.equals(this.additionalProperties, blockSuccess.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, commentStatuses); + return Objects.hash(status, commentStatuses, additionalProperties); } @Override @@ -137,6 +182,7 @@ public String toString() { sb.append("class BlockSuccess {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" commentStatuses: ").append(toIndentedString(commentStatuses)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -174,14 +220,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BlockSuccess.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BlockSuccess` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BlockSuccess.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -208,6 +246,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BlockSuccess value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -215,7 +275,28 @@ public void write(JsonWriter out, BlockSuccess value) throws IOException { public BlockSuccess read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BlockSuccess instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BuildModerationFilterResponse.java b/client/src/main/java/com/fastcomments/model/BuildModerationFilterResponse.java index 7a8e52e8..42550689 100644 --- a/client/src/main/java/com/fastcomments/model/BuildModerationFilterResponse.java +++ b/client/src/main/java/com/fastcomments/model/BuildModerationFilterResponse.java @@ -101,6 +101,50 @@ public void setModerationFilter(@javax.annotation.Nonnull ModerationFilter moder this.moderationFilter = moderationFilter; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BuildModerationFilterResponse instance itself + */ + public BuildModerationFilterResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -113,12 +157,13 @@ public boolean equals(Object o) { } BuildModerationFilterResponse buildModerationFilterResponse = (BuildModerationFilterResponse) o; return Objects.equals(this.status, buildModerationFilterResponse.status) && - Objects.equals(this.moderationFilter, buildModerationFilterResponse.moderationFilter); + Objects.equals(this.moderationFilter, buildModerationFilterResponse.moderationFilter)&& + Objects.equals(this.additionalProperties, buildModerationFilterResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, moderationFilter); + return Objects.hash(status, moderationFilter, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class BuildModerationFilterResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" moderationFilter: ").append(toIndentedString(moderationFilter)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -164,14 +210,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BuildModerationFilterResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BuildModerationFilterResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BuildModerationFilterResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BuildModerationFilterResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, BuildModerationFilterResponse value) throws IO public BuildModerationFilterResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BuildModerationFilterResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BulkAggregateQuestionItem.java b/client/src/main/java/com/fastcomments/model/BulkAggregateQuestionItem.java index 3b0af0fa..0151687d 100644 --- a/client/src/main/java/com/fastcomments/model/BulkAggregateQuestionItem.java +++ b/client/src/main/java/com/fastcomments/model/BulkAggregateQuestionItem.java @@ -208,6 +208,50 @@ public void setStartDate(@javax.annotation.Nullable OffsetDateTime startDate) { this.startDate = startDate; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BulkAggregateQuestionItem instance itself + */ + public BulkAggregateQuestionItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -224,12 +268,13 @@ public boolean equals(Object o) { Objects.equals(this.questionIds, bulkAggregateQuestionItem.questionIds) && Objects.equals(this.urlId, bulkAggregateQuestionItem.urlId) && Objects.equals(this.timeBucket, bulkAggregateQuestionItem.timeBucket) && - Objects.equals(this.startDate, bulkAggregateQuestionItem.startDate); + Objects.equals(this.startDate, bulkAggregateQuestionItem.startDate)&& + Objects.equals(this.additionalProperties, bulkAggregateQuestionItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(aggId, questionId, questionIds, urlId, timeBucket, startDate); + return Objects.hash(aggId, questionId, questionIds, urlId, timeBucket, startDate, additionalProperties); } @Override @@ -242,6 +287,7 @@ public String toString() { sb.append(" urlId: ").append(toIndentedString(urlId)).append("\n"); sb.append(" timeBucket: ").append(toIndentedString(timeBucket)).append("\n"); sb.append(" startDate: ").append(toIndentedString(startDate)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -279,14 +325,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BulkAggregateQuestionItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BulkAggregateQuestionItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BulkAggregateQuestionItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -328,6 +366,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BulkAggregateQuestionItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -335,7 +395,28 @@ public void write(JsonWriter out, BulkAggregateQuestionItem value) throws IOExce public BulkAggregateQuestionItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BulkAggregateQuestionItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BulkAggregateQuestionResultsRequest.java b/client/src/main/java/com/fastcomments/model/BulkAggregateQuestionResultsRequest.java index ebfe8924..a3cbe74f 100644 --- a/client/src/main/java/com/fastcomments/model/BulkAggregateQuestionResultsRequest.java +++ b/client/src/main/java/com/fastcomments/model/BulkAggregateQuestionResultsRequest.java @@ -87,6 +87,50 @@ public void setAggregations(@javax.annotation.Nonnull List additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BulkAggregateQuestionResultsRequest instance itself + */ + public BulkAggregateQuestionResultsRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -98,12 +142,13 @@ public boolean equals(Object o) { return false; } BulkAggregateQuestionResultsRequest bulkAggregateQuestionResultsRequest = (BulkAggregateQuestionResultsRequest) o; - return Objects.equals(this.aggregations, bulkAggregateQuestionResultsRequest.aggregations); + return Objects.equals(this.aggregations, bulkAggregateQuestionResultsRequest.aggregations)&& + Objects.equals(this.additionalProperties, bulkAggregateQuestionResultsRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(aggregations); + return Objects.hash(aggregations, additionalProperties); } @Override @@ -111,6 +156,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BulkAggregateQuestionResultsRequest {\n"); sb.append(" aggregations: ").append(toIndentedString(aggregations)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -148,14 +194,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BulkAggregateQuestionResultsRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BulkAggregateQuestionResultsRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BulkAggregateQuestionResultsRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -190,6 +228,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BulkAggregateQuestionResultsRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -197,7 +257,28 @@ public void write(JsonWriter out, BulkAggregateQuestionResultsRequest value) thr public BulkAggregateQuestionResultsRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BulkAggregateQuestionResultsRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BulkAggregateQuestionResultsResponse.java b/client/src/main/java/com/fastcomments/model/BulkAggregateQuestionResultsResponse.java index 975569f2..8ecda469 100644 --- a/client/src/main/java/com/fastcomments/model/BulkAggregateQuestionResultsResponse.java +++ b/client/src/main/java/com/fastcomments/model/BulkAggregateQuestionResultsResponse.java @@ -112,6 +112,50 @@ public void setData(@javax.annotation.Nonnull Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BulkAggregateQuestionResultsResponse instance itself + */ + public BulkAggregateQuestionResultsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } BulkAggregateQuestionResultsResponse bulkAggregateQuestionResultsResponse = (BulkAggregateQuestionResultsResponse) o; return Objects.equals(this.status, bulkAggregateQuestionResultsResponse.status) && - Objects.equals(this.data, bulkAggregateQuestionResultsResponse.data); + Objects.equals(this.data, bulkAggregateQuestionResultsResponse.data)&& + Objects.equals(this.additionalProperties, bulkAggregateQuestionResultsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, data); + return Objects.hash(status, data, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class BulkAggregateQuestionResultsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BulkAggregateQuestionResultsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BulkAggregateQuestionResultsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BulkAggregateQuestionResultsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -209,6 +247,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BulkAggregateQuestionResultsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -216,7 +276,28 @@ public void write(JsonWriter out, BulkAggregateQuestionResultsResponse value) th public BulkAggregateQuestionResultsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BulkAggregateQuestionResultsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BulkCreateHashTagsBody.java b/client/src/main/java/com/fastcomments/model/BulkCreateHashTagsBody.java index f1f3854b..3e7a3319 100644 --- a/client/src/main/java/com/fastcomments/model/BulkCreateHashTagsBody.java +++ b/client/src/main/java/com/fastcomments/model/BulkCreateHashTagsBody.java @@ -111,6 +111,50 @@ public void setTags(@javax.annotation.Nonnull List additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BulkCreateHashTagsBody instance itself + */ + public BulkCreateHashTagsBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -123,12 +167,13 @@ public boolean equals(Object o) { } BulkCreateHashTagsBody bulkCreateHashTagsBody = (BulkCreateHashTagsBody) o; return Objects.equals(this.tenantId, bulkCreateHashTagsBody.tenantId) && - Objects.equals(this.tags, bulkCreateHashTagsBody.tags); + Objects.equals(this.tags, bulkCreateHashTagsBody.tags)&& + Objects.equals(this.additionalProperties, bulkCreateHashTagsBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tenantId, tags); + return Objects.hash(tenantId, tags, additionalProperties); } @Override @@ -137,6 +182,7 @@ public String toString() { sb.append("class BulkCreateHashTagsBody {\n"); sb.append(" tenantId: ").append(toIndentedString(tenantId)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -174,14 +220,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BulkCreateHashTagsBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BulkCreateHashTagsBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BulkCreateHashTagsBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BulkCreateHashTagsBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, BulkCreateHashTagsBody value) throws IOExcepti public BulkCreateHashTagsBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BulkCreateHashTagsBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BulkCreateHashTagsResponse.java b/client/src/main/java/com/fastcomments/model/BulkCreateHashTagsResponse.java index 9b514a96..9494ffd3 100644 --- a/client/src/main/java/com/fastcomments/model/BulkCreateHashTagsResponse.java +++ b/client/src/main/java/com/fastcomments/model/BulkCreateHashTagsResponse.java @@ -112,6 +112,50 @@ public void setResults(@javax.annotation.Nonnull List additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BulkCreateHashTagsResponse instance itself + */ + public BulkCreateHashTagsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } BulkCreateHashTagsResponse bulkCreateHashTagsResponse = (BulkCreateHashTagsResponse) o; return Objects.equals(this.status, bulkCreateHashTagsResponse.status) && - Objects.equals(this.results, bulkCreateHashTagsResponse.results); + Objects.equals(this.results, bulkCreateHashTagsResponse.results)&& + Objects.equals(this.additionalProperties, bulkCreateHashTagsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, results); + return Objects.hash(status, results, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class BulkCreateHashTagsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" results: ").append(toIndentedString(results)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BulkCreateHashTagsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BulkCreateHashTagsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BulkCreateHashTagsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BulkCreateHashTagsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, BulkCreateHashTagsResponse value) throws IOExc public BulkCreateHashTagsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BulkCreateHashTagsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BulkPreBanParams.java b/client/src/main/java/com/fastcomments/model/BulkPreBanParams.java index e4a4b414..e47efd76 100644 --- a/client/src/main/java/com/fastcomments/model/BulkPreBanParams.java +++ b/client/src/main/java/com/fastcomments/model/BulkPreBanParams.java @@ -86,6 +86,50 @@ public void setCommentIds(@javax.annotation.Nonnull List commentIds) { this.commentIds = commentIds; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BulkPreBanParams instance itself + */ + public BulkPreBanParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } BulkPreBanParams bulkPreBanParams = (BulkPreBanParams) o; - return Objects.equals(this.commentIds, bulkPreBanParams.commentIds); + return Objects.equals(this.commentIds, bulkPreBanParams.commentIds)&& + Objects.equals(this.additionalProperties, bulkPreBanParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(commentIds); + return Objects.hash(commentIds, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BulkPreBanParams {\n"); sb.append(" commentIds: ").append(toIndentedString(commentIds)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BulkPreBanParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BulkPreBanParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BulkPreBanParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -185,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BulkPreBanParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -192,7 +252,28 @@ public void write(JsonWriter out, BulkPreBanParams value) throws IOException { public BulkPreBanParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BulkPreBanParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/BulkPreBanSummary.java b/client/src/main/java/com/fastcomments/model/BulkPreBanSummary.java index 4ba65f79..c8190b8d 100644 --- a/client/src/main/java/com/fastcomments/model/BulkPreBanSummary.java +++ b/client/src/main/java/com/fastcomments/model/BulkPreBanSummary.java @@ -230,6 +230,50 @@ public void setIpHashes(@javax.annotation.Nonnull List ipHashes) { this.ipHashes = ipHashes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the BulkPreBanSummary instance itself + */ + public BulkPreBanSummary putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -246,12 +290,13 @@ public boolean equals(Object o) { Objects.equals(this.emailDomains, bulkPreBanSummary.emailDomains) && Objects.equals(this.emails, bulkPreBanSummary.emails) && Objects.equals(this.userIds, bulkPreBanSummary.userIds) && - Objects.equals(this.ipHashes, bulkPreBanSummary.ipHashes); + Objects.equals(this.ipHashes, bulkPreBanSummary.ipHashes)&& + Objects.equals(this.additionalProperties, bulkPreBanSummary.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, totalRelatedCommentCount, emailDomains, emails, userIds, ipHashes); + return Objects.hash(status, totalRelatedCommentCount, emailDomains, emails, userIds, ipHashes, additionalProperties); } @Override @@ -264,6 +309,7 @@ public String toString() { sb.append(" emails: ").append(toIndentedString(emails)).append("\n"); sb.append(" userIds: ").append(toIndentedString(userIds)).append("\n"); sb.append(" ipHashes: ").append(toIndentedString(ipHashes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -301,14 +347,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BulkPreBanSummary.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BulkPreBanSummary` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BulkPreBanSummary.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -360,6 +398,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BulkPreBanSummary value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -367,7 +427,28 @@ public void write(JsonWriter out, BulkPreBanSummary value) throws IOException { public BulkPreBanSummary read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + BulkPreBanSummary instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ChangeTicketStateBody.java b/client/src/main/java/com/fastcomments/model/ChangeTicketStateBody.java index c77440be..068567d3 100644 --- a/client/src/main/java/com/fastcomments/model/ChangeTicketStateBody.java +++ b/client/src/main/java/com/fastcomments/model/ChangeTicketStateBody.java @@ -76,6 +76,50 @@ public void setState(@javax.annotation.Nonnull Integer state) { this.state = state; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ChangeTicketStateBody instance itself + */ + public ChangeTicketStateBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -87,12 +131,13 @@ public boolean equals(Object o) { return false; } ChangeTicketStateBody changeTicketStateBody = (ChangeTicketStateBody) o; - return Objects.equals(this.state, changeTicketStateBody.state); + return Objects.equals(this.state, changeTicketStateBody.state)&& + Objects.equals(this.additionalProperties, changeTicketStateBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(state); + return Objects.hash(state, additionalProperties); } @Override @@ -100,6 +145,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ChangeTicketStateBody {\n"); sb.append(" state: ").append(toIndentedString(state)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -137,14 +183,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ChangeTicketStateBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ChangeTicketStateBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ChangeTicketStateBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -169,6 +207,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ChangeTicketStateBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -176,7 +236,28 @@ public void write(JsonWriter out, ChangeTicketStateBody value) throws IOExceptio public ChangeTicketStateBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ChangeTicketStateBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ChangeTicketStateResponse.java b/client/src/main/java/com/fastcomments/model/ChangeTicketStateResponse.java index f8fc4b0d..65c623e1 100644 --- a/client/src/main/java/com/fastcomments/model/ChangeTicketStateResponse.java +++ b/client/src/main/java/com/fastcomments/model/ChangeTicketStateResponse.java @@ -102,6 +102,50 @@ public void setTicket(@javax.annotation.Nonnull APITicket ticket) { this.ticket = ticket; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ChangeTicketStateResponse instance itself + */ + public ChangeTicketStateResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } ChangeTicketStateResponse changeTicketStateResponse = (ChangeTicketStateResponse) o; return Objects.equals(this.status, changeTicketStateResponse.status) && - Objects.equals(this.ticket, changeTicketStateResponse.ticket); + Objects.equals(this.ticket, changeTicketStateResponse.ticket)&& + Objects.equals(this.additionalProperties, changeTicketStateResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, ticket); + return Objects.hash(status, ticket, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class ChangeTicketStateResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" ticket: ").append(toIndentedString(ticket)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ChangeTicketStateResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ChangeTicketStateResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ChangeTicketStateResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ChangeTicketStateResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, ChangeTicketStateResponse value) throws IOExce public ChangeTicketStateResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ChangeTicketStateResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CombineQuestionResultsWithCommentsResponse.java b/client/src/main/java/com/fastcomments/model/CombineQuestionResultsWithCommentsResponse.java index 01dfe207..3bbf65fe 100644 --- a/client/src/main/java/com/fastcomments/model/CombineQuestionResultsWithCommentsResponse.java +++ b/client/src/main/java/com/fastcomments/model/CombineQuestionResultsWithCommentsResponse.java @@ -102,6 +102,50 @@ public void setData(@javax.annotation.Nonnull FindCommentsByRangeResponse data) this.data = data; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CombineQuestionResultsWithCommentsResponse instance itself + */ + public CombineQuestionResultsWithCommentsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } CombineQuestionResultsWithCommentsResponse combineQuestionResultsWithCommentsResponse = (CombineQuestionResultsWithCommentsResponse) o; return Objects.equals(this.status, combineQuestionResultsWithCommentsResponse.status) && - Objects.equals(this.data, combineQuestionResultsWithCommentsResponse.data); + Objects.equals(this.data, combineQuestionResultsWithCommentsResponse.data)&& + Objects.equals(this.additionalProperties, combineQuestionResultsWithCommentsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, data); + return Objects.hash(status, data, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class CombineQuestionResultsWithCommentsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CombineQuestionResultsWithCommentsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CombineQuestionResultsWithCommentsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CombineQuestionResultsWithCommentsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CombineQuestionResultsWithCommentsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CombineQuestionResultsWithCommentsResponse val public CombineQuestionResultsWithCommentsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CombineQuestionResultsWithCommentsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentData.java b/client/src/main/java/com/fastcomments/model/CommentData.java index e58049a9..61ae14fd 100644 --- a/client/src/main/java/com/fastcomments/model/CommentData.java +++ b/client/src/main/java/com/fastcomments/model/CommentData.java @@ -748,6 +748,50 @@ public void setBotId(@javax.annotation.Nullable String botId) { this.botId = botId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentData instance itself + */ + public CommentData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -785,12 +829,13 @@ public boolean equals(Object o) { Objects.equals(this.questionValues, commentData.questionValues) && Objects.equals(this.poll, commentData.poll) && Objects.equals(this.tos, commentData.tos) && - Objects.equals(this.botId, commentData.botId); + Objects.equals(this.botId, commentData.botId)&& + Objects.equals(this.additionalProperties, commentData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(date, localDateString, localDateHours, commenterName, commenterEmail, commenterLink, comment, productId, userId, avatarSrc, parentId, mentions, hashTags, pageTitle, isFromMyAccountPage, url, urlId, meta, moderationGroupIds, rating, fromOfflineRestore, autoplayDelayMS, feedbackIds, questionValues, poll, tos, botId); + return Objects.hash(date, localDateString, localDateHours, commenterName, commenterEmail, commenterLink, comment, productId, userId, avatarSrc, parentId, mentions, hashTags, pageTitle, isFromMyAccountPage, url, urlId, meta, moderationGroupIds, rating, fromOfflineRestore, autoplayDelayMS, feedbackIds, questionValues, poll, tos, botId, additionalProperties); } @Override @@ -824,6 +869,7 @@ public String toString() { sb.append(" poll: ").append(toIndentedString(poll)).append("\n"); sb.append(" tos: ").append(toIndentedString(tos)).append("\n"); sb.append(" botId: ").append(toIndentedString(botId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -861,14 +907,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -969,6 +1007,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -976,7 +1036,28 @@ public void write(JsonWriter out, CommentData value) throws IOException { public CommentData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentLogData.java b/client/src/main/java/com/fastcomments/model/CommentLogData.java index 14266650..0e1ad637 100644 --- a/client/src/main/java/com/fastcomments/model/CommentLogData.java +++ b/client/src/main/java/com/fastcomments/model/CommentLogData.java @@ -1331,6 +1331,50 @@ public void setEmailQueued(@javax.annotation.Nullable Boolean emailQueued) { this.emailQueued = emailQueued; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentLogData instance itself + */ + public CommentLogData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -1392,12 +1436,13 @@ public boolean equals(Object o) { Objects.equals(this.detectedLanguage, commentLogData.detectedLanguage) && Objects.equals(this.recipientUserId, commentLogData.recipientUserId) && Objects.equals(this.notifySkipReason, commentLogData.notifySkipReason) && - Objects.equals(this.emailQueued, commentLogData.emailQueued); + Objects.equals(this.emailQueued, commentLogData.emailQueued)&& + Objects.equals(this.additionalProperties, commentLogData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(clearContent, isDeletedUser, phrase, badWord, word, locale, tenantBadgeId, badgeId, wasLoggedIn, foundUser, verified, engine, engineResponse, engineTokens, trustFactor, source, rule, userId, subscribers, notificationCount, votesBefore, votesUpBefore, votesDownBefore, votesAfter, votesUpAfter, votesDownAfter, repeatAction, reason, skipReason, otherData, spamBefore, spamAfter, permanentFlag, approvedBefore, approvedAfter, reviewedBefore, reviewedAfter, textBefore, textAfter, expireBefore, expireAfter, flagCountBefore, trustFactorBefore, trustFactorAfter, referencedCommentId, invalidLocale, detectedLocale, detectedLanguage, recipientUserId, notifySkipReason, emailQueued); + return Objects.hash(clearContent, isDeletedUser, phrase, badWord, word, locale, tenantBadgeId, badgeId, wasLoggedIn, foundUser, verified, engine, engineResponse, engineTokens, trustFactor, source, rule, userId, subscribers, notificationCount, votesBefore, votesUpBefore, votesDownBefore, votesAfter, votesUpAfter, votesDownAfter, repeatAction, reason, skipReason, otherData, spamBefore, spamAfter, permanentFlag, approvedBefore, approvedAfter, reviewedBefore, reviewedAfter, textBefore, textAfter, expireBefore, expireAfter, flagCountBefore, trustFactorBefore, trustFactorAfter, referencedCommentId, invalidLocale, detectedLocale, detectedLanguage, recipientUserId, notifySkipReason, emailQueued, additionalProperties); } @Override @@ -1455,6 +1500,7 @@ public String toString() { sb.append(" recipientUserId: ").append(toIndentedString(recipientUserId)).append("\n"); sb.append(" notifySkipReason: ").append(toIndentedString(notifySkipReason)).append("\n"); sb.append(" emailQueued: ").append(toIndentedString(emailQueued)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -1491,14 +1537,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CommentLogData is not found in the empty JSON string", CommentLogData.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentLogData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentLogData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("phrase") != null && !jsonObj.get("phrase").isJsonNull()) && !jsonObj.get("phrase").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `phrase` to be a primitive type in the JSON string but got `%s`", jsonObj.get("phrase").toString())); @@ -1594,6 +1632,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentLogData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -1601,7 +1661,28 @@ public void write(JsonWriter out, CommentLogData value) throws IOException { public CommentLogData read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentLogData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentLogEntry.java b/client/src/main/java/com/fastcomments/model/CommentLogEntry.java index 181b40e2..8f8f8a09 100644 --- a/client/src/main/java/com/fastcomments/model/CommentLogEntry.java +++ b/client/src/main/java/com/fastcomments/model/CommentLogEntry.java @@ -127,6 +127,50 @@ public void setDa(@javax.annotation.Nullable CommentLogData da) { this.da = da; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentLogEntry instance itself + */ + public CommentLogEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -140,12 +184,13 @@ public boolean equals(Object o) { CommentLogEntry commentLogEntry = (CommentLogEntry) o; return Objects.equals(this.d, commentLogEntry.d) && Objects.equals(this.t, commentLogEntry.t) && - Objects.equals(this.da, commentLogEntry.da); + Objects.equals(this.da, commentLogEntry.da)&& + Objects.equals(this.additionalProperties, commentLogEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(d, t, da); + return Objects.hash(d, t, da, additionalProperties); } @Override @@ -155,6 +200,7 @@ public String toString() { sb.append(" d: ").append(toIndentedString(d)).append("\n"); sb.append(" t: ").append(toIndentedString(t)).append("\n"); sb.append(" da: ").append(toIndentedString(da)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -192,14 +238,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentLogEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentLogEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentLogEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -230,6 +268,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentLogEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -237,7 +297,28 @@ public void write(JsonWriter out, CommentLogEntry value) throws IOException { public CommentLogEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentLogEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentPoll.java b/client/src/main/java/com/fastcomments/model/CommentPoll.java index 4cb04157..4161bfd3 100644 --- a/client/src/main/java/com/fastcomments/model/CommentPoll.java +++ b/client/src/main/java/com/fastcomments/model/CommentPoll.java @@ -209,6 +209,50 @@ public void setRequireVoteToSeeResults(@javax.annotation.Nullable Boolean requir this.requireVoteToSeeResults = requireVoteToSeeResults; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentPoll instance itself + */ + public CommentPoll putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -225,12 +269,13 @@ public boolean equals(Object o) { Objects.equals(this.totalVotes, commentPoll.totalVotes) && Objects.equals(this.closesAt, commentPoll.closesAt) && Objects.equals(this.privacy, commentPoll.privacy) && - Objects.equals(this.requireVoteToSeeResults, commentPoll.requireVoteToSeeResults); + Objects.equals(this.requireVoteToSeeResults, commentPoll.requireVoteToSeeResults)&& + Objects.equals(this.additionalProperties, commentPoll.additionalProperties); } @Override public int hashCode() { - return Objects.hash(question, options, totalVotes, closesAt, privacy, requireVoteToSeeResults); + return Objects.hash(question, options, totalVotes, closesAt, privacy, requireVoteToSeeResults, additionalProperties); } @Override @@ -243,6 +288,7 @@ public String toString() { sb.append(" closesAt: ").append(toIndentedString(closesAt)).append("\n"); sb.append(" privacy: ").append(toIndentedString(privacy)).append("\n"); sb.append(" requireVoteToSeeResults: ").append(toIndentedString(requireVoteToSeeResults)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -280,14 +326,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentPoll.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentPoll` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentPoll.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -329,6 +367,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentPoll value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -336,7 +396,28 @@ public void write(JsonWriter out, CommentPoll value) throws IOException { public CommentPoll read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentPoll instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentPollInput.java b/client/src/main/java/com/fastcomments/model/CommentPollInput.java index 68d273e0..1994b4b8 100644 --- a/client/src/main/java/com/fastcomments/model/CommentPollInput.java +++ b/client/src/main/java/com/fastcomments/model/CommentPollInput.java @@ -182,6 +182,50 @@ public void setRequireVoteToSeeResults(@javax.annotation.Nullable Boolean requir this.requireVoteToSeeResults = requireVoteToSeeResults; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentPollInput instance itself + */ + public CommentPollInput putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -197,12 +241,13 @@ public boolean equals(Object o) { Objects.equals(this.options, commentPollInput.options) && Objects.equals(this.closesAt, commentPollInput.closesAt) && Objects.equals(this.privacy, commentPollInput.privacy) && - Objects.equals(this.requireVoteToSeeResults, commentPollInput.requireVoteToSeeResults); + Objects.equals(this.requireVoteToSeeResults, commentPollInput.requireVoteToSeeResults)&& + Objects.equals(this.additionalProperties, commentPollInput.additionalProperties); } @Override public int hashCode() { - return Objects.hash(question, options, closesAt, privacy, requireVoteToSeeResults); + return Objects.hash(question, options, closesAt, privacy, requireVoteToSeeResults, additionalProperties); } @Override @@ -214,6 +259,7 @@ public String toString() { sb.append(" closesAt: ").append(toIndentedString(closesAt)).append("\n"); sb.append(" privacy: ").append(toIndentedString(privacy)).append("\n"); sb.append(" requireVoteToSeeResults: ").append(toIndentedString(requireVoteToSeeResults)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -251,14 +297,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentPollInput.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentPollInput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentPollInput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -295,6 +333,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentPollInput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -302,7 +362,28 @@ public void write(JsonWriter out, CommentPollInput value) throws IOException { public CommentPollInput read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentPollInput instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentPollOption.java b/client/src/main/java/com/fastcomments/model/CommentPollOption.java index 4bd8a0d1..9b69bf2e 100644 --- a/client/src/main/java/com/fastcomments/model/CommentPollOption.java +++ b/client/src/main/java/com/fastcomments/model/CommentPollOption.java @@ -124,6 +124,50 @@ public void setVotes(@javax.annotation.Nonnull Integer votes) { this.votes = votes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentPollOption instance itself + */ + public CommentPollOption putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -137,12 +181,13 @@ public boolean equals(Object o) { CommentPollOption commentPollOption = (CommentPollOption) o; return Objects.equals(this.id, commentPollOption.id) && Objects.equals(this.label, commentPollOption.label) && - Objects.equals(this.votes, commentPollOption.votes); + Objects.equals(this.votes, commentPollOption.votes)&& + Objects.equals(this.additionalProperties, commentPollOption.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, label, votes); + return Objects.hash(id, label, votes, additionalProperties); } @Override @@ -152,6 +197,7 @@ public String toString() { sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" label: ").append(toIndentedString(label)).append("\n"); sb.append(" votes: ").append(toIndentedString(votes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -189,14 +235,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentPollOption.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentPollOption` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentPollOption.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -227,6 +265,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentPollOption value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -234,7 +294,28 @@ public void write(JsonWriter out, CommentPollOption value) throws IOException { public CommentPollOption read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentPollOption instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentPollOptionInput.java b/client/src/main/java/com/fastcomments/model/CommentPollOptionInput.java index 187b4c7b..f4f835f8 100644 --- a/client/src/main/java/com/fastcomments/model/CommentPollOptionInput.java +++ b/client/src/main/java/com/fastcomments/model/CommentPollOptionInput.java @@ -100,6 +100,50 @@ public void setLabel(@javax.annotation.Nonnull String label) { this.label = label; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentPollOptionInput instance itself + */ + public CommentPollOptionInput putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -112,12 +156,13 @@ public boolean equals(Object o) { } CommentPollOptionInput commentPollOptionInput = (CommentPollOptionInput) o; return Objects.equals(this.id, commentPollOptionInput.id) && - Objects.equals(this.label, commentPollOptionInput.label); + Objects.equals(this.label, commentPollOptionInput.label)&& + Objects.equals(this.additionalProperties, commentPollOptionInput.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, label); + return Objects.hash(id, label, additionalProperties); } @Override @@ -126,6 +171,7 @@ public String toString() { sb.append("class CommentPollOptionInput {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" label: ").append(toIndentedString(label)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -163,14 +209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentPollOptionInput.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentPollOptionInput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentPollOptionInput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentPollOptionInput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CommentPollOptionInput value) throws IOExcepti public CommentPollOptionInput read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentPollOptionInput instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentPollPatch.java b/client/src/main/java/com/fastcomments/model/CommentPollPatch.java index 915da23c..8a5b16d8 100644 --- a/client/src/main/java/com/fastcomments/model/CommentPollPatch.java +++ b/client/src/main/java/com/fastcomments/model/CommentPollPatch.java @@ -183,6 +183,50 @@ public void setRequireVoteToSeeResults(@javax.annotation.Nullable Boolean requir this.requireVoteToSeeResults = requireVoteToSeeResults; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentPollPatch instance itself + */ + public CommentPollPatch putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -198,12 +242,13 @@ public boolean equals(Object o) { Objects.equals(this.options, commentPollPatch.options) && Objects.equals(this.closesAt, commentPollPatch.closesAt) && Objects.equals(this.privacy, commentPollPatch.privacy) && - Objects.equals(this.requireVoteToSeeResults, commentPollPatch.requireVoteToSeeResults); + Objects.equals(this.requireVoteToSeeResults, commentPollPatch.requireVoteToSeeResults)&& + Objects.equals(this.additionalProperties, commentPollPatch.additionalProperties); } @Override public int hashCode() { - return Objects.hash(question, options, closesAt, privacy, requireVoteToSeeResults); + return Objects.hash(question, options, closesAt, privacy, requireVoteToSeeResults, additionalProperties); } @Override @@ -215,6 +260,7 @@ public String toString() { sb.append(" closesAt: ").append(toIndentedString(closesAt)).append("\n"); sb.append(" privacy: ").append(toIndentedString(privacy)).append("\n"); sb.append(" requireVoteToSeeResults: ").append(toIndentedString(requireVoteToSeeResults)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -251,14 +297,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CommentPollPatch is not found in the empty JSON string", CommentPollPatch.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentPollPatch.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentPollPatch` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("question") != null && !jsonObj.get("question").isJsonNull()) && !jsonObj.get("question").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `question` to be a primitive type in the JSON string but got `%s`", jsonObj.get("question").toString())); @@ -297,6 +335,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentPollPatch value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -304,7 +364,28 @@ public void write(JsonWriter out, CommentPollPatch value) throws IOException { public CommentPollPatch read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentPollPatch instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentPollPutInput.java b/client/src/main/java/com/fastcomments/model/CommentPollPutInput.java index 994dc603..34322873 100644 --- a/client/src/main/java/com/fastcomments/model/CommentPollPutInput.java +++ b/client/src/main/java/com/fastcomments/model/CommentPollPutInput.java @@ -183,6 +183,50 @@ public void setRequireVoteToSeeResults(@javax.annotation.Nullable Boolean requir this.requireVoteToSeeResults = requireVoteToSeeResults; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentPollPutInput instance itself + */ + public CommentPollPutInput putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -198,12 +242,13 @@ public boolean equals(Object o) { Objects.equals(this.options, commentPollPutInput.options) && Objects.equals(this.closesAt, commentPollPutInput.closesAt) && Objects.equals(this.privacy, commentPollPutInput.privacy) && - Objects.equals(this.requireVoteToSeeResults, commentPollPutInput.requireVoteToSeeResults); + Objects.equals(this.requireVoteToSeeResults, commentPollPutInput.requireVoteToSeeResults)&& + Objects.equals(this.additionalProperties, commentPollPutInput.additionalProperties); } @Override public int hashCode() { - return Objects.hash(question, options, closesAt, privacy, requireVoteToSeeResults); + return Objects.hash(question, options, closesAt, privacy, requireVoteToSeeResults, additionalProperties); } @Override @@ -215,6 +260,7 @@ public String toString() { sb.append(" closesAt: ").append(toIndentedString(closesAt)).append("\n"); sb.append(" privacy: ").append(toIndentedString(privacy)).append("\n"); sb.append(" requireVoteToSeeResults: ").append(toIndentedString(requireVoteToSeeResults)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -252,14 +298,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentPollPutInput.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentPollPutInput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentPollPutInput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -300,6 +338,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentPollPutInput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -307,7 +367,28 @@ public void write(JsonWriter out, CommentPollPutInput value) throws IOException public CommentPollPutInput read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentPollPutInput instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentTextUpdateRequest.java b/client/src/main/java/com/fastcomments/model/CommentTextUpdateRequest.java index b2cc43c8..edda1ed3 100644 --- a/client/src/main/java/com/fastcomments/model/CommentTextUpdateRequest.java +++ b/client/src/main/java/com/fastcomments/model/CommentTextUpdateRequest.java @@ -144,6 +144,50 @@ public void setHashTags(@javax.annotation.Nullable List this.hashTags = hashTags; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentTextUpdateRequest instance itself + */ + public CommentTextUpdateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -157,12 +201,13 @@ public boolean equals(Object o) { CommentTextUpdateRequest commentTextUpdateRequest = (CommentTextUpdateRequest) o; return Objects.equals(this.comment, commentTextUpdateRequest.comment) && Objects.equals(this.mentions, commentTextUpdateRequest.mentions) && - Objects.equals(this.hashTags, commentTextUpdateRequest.hashTags); + Objects.equals(this.hashTags, commentTextUpdateRequest.hashTags)&& + Objects.equals(this.additionalProperties, commentTextUpdateRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(comment, mentions, hashTags); + return Objects.hash(comment, mentions, hashTags, additionalProperties); } @Override @@ -172,6 +217,7 @@ public String toString() { sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); sb.append(" mentions: ").append(toIndentedString(mentions)).append("\n"); sb.append(" hashTags: ").append(toIndentedString(hashTags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -209,14 +255,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentTextUpdateRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentTextUpdateRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentTextUpdateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -272,6 +310,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentTextUpdateRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -279,7 +339,28 @@ public void write(JsonWriter out, CommentTextUpdateRequest value) throws IOExcep public CommentTextUpdateRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentTextUpdateRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentTranslation.java b/client/src/main/java/com/fastcomments/model/CommentTranslation.java index e9c2e561..350f3d9b 100644 --- a/client/src/main/java/com/fastcomments/model/CommentTranslation.java +++ b/client/src/main/java/com/fastcomments/model/CommentTranslation.java @@ -173,6 +173,50 @@ public void setCreatedAt(@javax.annotation.Nonnull OffsetDateTime createdAt) { this.createdAt = createdAt; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentTranslation instance itself + */ + public CommentTranslation putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -188,12 +232,13 @@ public boolean equals(Object o) { Objects.equals(this.commentHTML, commentTranslation.commentHTML) && Objects.equals(this.sourceLanguage, commentTranslation.sourceLanguage) && Objects.equals(this.model, commentTranslation.model) && - Objects.equals(this.createdAt, commentTranslation.createdAt); + Objects.equals(this.createdAt, commentTranslation.createdAt)&& + Objects.equals(this.additionalProperties, commentTranslation.additionalProperties); } @Override public int hashCode() { - return Objects.hash(comment, commentHTML, sourceLanguage, model, createdAt); + return Objects.hash(comment, commentHTML, sourceLanguage, model, createdAt, additionalProperties); } @Override @@ -205,6 +250,7 @@ public String toString() { sb.append(" sourceLanguage: ").append(toIndentedString(sourceLanguage)).append("\n"); sb.append(" model: ").append(toIndentedString(model)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -242,14 +288,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentTranslation.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentTranslation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentTranslation.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -286,6 +324,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentTranslation value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -293,7 +353,28 @@ public void write(JsonWriter out, CommentTranslation value) throws IOException { public CommentTranslation read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentTranslation instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentTranslationPublic.java b/client/src/main/java/com/fastcomments/model/CommentTranslationPublic.java index efeabe22..91b8e509 100644 --- a/client/src/main/java/com/fastcomments/model/CommentTranslationPublic.java +++ b/client/src/main/java/com/fastcomments/model/CommentTranslationPublic.java @@ -100,6 +100,50 @@ public void setSourceLanguage(@javax.annotation.Nonnull String sourceLanguage) { this.sourceLanguage = sourceLanguage; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentTranslationPublic instance itself + */ + public CommentTranslationPublic putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -112,12 +156,13 @@ public boolean equals(Object o) { } CommentTranslationPublic commentTranslationPublic = (CommentTranslationPublic) o; return Objects.equals(this.commentHTML, commentTranslationPublic.commentHTML) && - Objects.equals(this.sourceLanguage, commentTranslationPublic.sourceLanguage); + Objects.equals(this.sourceLanguage, commentTranslationPublic.sourceLanguage)&& + Objects.equals(this.additionalProperties, commentTranslationPublic.additionalProperties); } @Override public int hashCode() { - return Objects.hash(commentHTML, sourceLanguage); + return Objects.hash(commentHTML, sourceLanguage, additionalProperties); } @Override @@ -126,6 +171,7 @@ public String toString() { sb.append("class CommentTranslationPublic {\n"); sb.append(" commentHTML: ").append(toIndentedString(commentHTML)).append("\n"); sb.append(" sourceLanguage: ").append(toIndentedString(sourceLanguage)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -163,14 +209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentTranslationPublic.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentTranslationPublic` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentTranslationPublic.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentTranslationPublic value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CommentTranslationPublic value) throws IOExcep public CommentTranslationPublic read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentTranslationPublic instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentTranslationsRequest.java b/client/src/main/java/com/fastcomments/model/CommentTranslationsRequest.java index 0cdb4486..b425cf52 100644 --- a/client/src/main/java/com/fastcomments/model/CommentTranslationsRequest.java +++ b/client/src/main/java/com/fastcomments/model/CommentTranslationsRequest.java @@ -86,6 +86,50 @@ public void setCommentIds(@javax.annotation.Nonnull List commentIds) { this.commentIds = commentIds; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentTranslationsRequest instance itself + */ + public CommentTranslationsRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } CommentTranslationsRequest commentTranslationsRequest = (CommentTranslationsRequest) o; - return Objects.equals(this.commentIds, commentTranslationsRequest.commentIds); + return Objects.equals(this.commentIds, commentTranslationsRequest.commentIds)&& + Objects.equals(this.additionalProperties, commentTranslationsRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(commentIds); + return Objects.hash(commentIds, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CommentTranslationsRequest {\n"); sb.append(" commentIds: ").append(toIndentedString(commentIds)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentTranslationsRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentTranslationsRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentTranslationsRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -185,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentTranslationsRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -192,7 +252,28 @@ public void write(JsonWriter out, CommentTranslationsRequest value) throws IOExc public CommentTranslationsRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentTranslationsRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentTranslationsResponse.java b/client/src/main/java/com/fastcomments/model/CommentTranslationsResponse.java index 5dd98aae..36b1982f 100644 --- a/client/src/main/java/com/fastcomments/model/CommentTranslationsResponse.java +++ b/client/src/main/java/com/fastcomments/model/CommentTranslationsResponse.java @@ -170,6 +170,50 @@ public void setFailed(@javax.annotation.Nonnull List failed) { this.failed = failed; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentTranslationsResponse instance itself + */ + public CommentTranslationsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -184,12 +228,13 @@ public boolean equals(Object o) { return Objects.equals(this.status, commentTranslationsResponse.status) && Objects.equals(this.locale, commentTranslationsResponse.locale) && Objects.equals(this.translations, commentTranslationsResponse.translations) && - Objects.equals(this.failed, commentTranslationsResponse.failed); + Objects.equals(this.failed, commentTranslationsResponse.failed)&& + Objects.equals(this.additionalProperties, commentTranslationsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, locale, translations, failed); + return Objects.hash(status, locale, translations, failed, additionalProperties); } @Override @@ -200,6 +245,7 @@ public String toString() { sb.append(" locale: ").append(toIndentedString(locale)).append("\n"); sb.append(" translations: ").append(toIndentedString(translations)).append("\n"); sb.append(" failed: ").append(toIndentedString(failed)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -237,14 +283,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentTranslationsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentTranslationsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentTranslationsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -280,6 +318,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentTranslationsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -287,7 +347,28 @@ public void write(JsonWriter out, CommentTranslationsResponse value) throws IOEx public CommentTranslationsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentTranslationsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentUserBadgeInfo.java b/client/src/main/java/com/fastcomments/model/CommentUserBadgeInfo.java index 5d9c8691..54398c9d 100644 --- a/client/src/main/java/com/fastcomments/model/CommentUserBadgeInfo.java +++ b/client/src/main/java/com/fastcomments/model/CommentUserBadgeInfo.java @@ -268,6 +268,50 @@ public void setCssClass(@javax.annotation.Nullable String cssClass) { this.cssClass = cssClass; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentUserBadgeInfo instance itself + */ + public CommentUserBadgeInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -287,12 +331,13 @@ public boolean equals(Object o) { Objects.equals(this.backgroundColor, commentUserBadgeInfo.backgroundColor) && Objects.equals(this.borderColor, commentUserBadgeInfo.borderColor) && Objects.equals(this.textColor, commentUserBadgeInfo.textColor) && - Objects.equals(this.cssClass, commentUserBadgeInfo.cssClass); + Objects.equals(this.cssClass, commentUserBadgeInfo.cssClass)&& + Objects.equals(this.additionalProperties, commentUserBadgeInfo.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, type, description, displayLabel, displaySrc, backgroundColor, borderColor, textColor, cssClass); + return Objects.hash(id, type, description, displayLabel, displaySrc, backgroundColor, borderColor, textColor, cssClass, additionalProperties); } @Override @@ -308,6 +353,7 @@ public String toString() { sb.append(" borderColor: ").append(toIndentedString(borderColor)).append("\n"); sb.append(" textColor: ").append(toIndentedString(textColor)).append("\n"); sb.append(" cssClass: ").append(toIndentedString(cssClass)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -345,14 +391,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentUserBadgeInfo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentUserBadgeInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentUserBadgeInfo.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -401,6 +439,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentUserBadgeInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -408,7 +468,28 @@ public void write(JsonWriter out, CommentUserBadgeInfo value) throws IOException public CommentUserBadgeInfo read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentUserBadgeInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentUserHashTagInfo.java b/client/src/main/java/com/fastcomments/model/CommentUserHashTagInfo.java index 7e79b659..5fb793fb 100644 --- a/client/src/main/java/com/fastcomments/model/CommentUserHashTagInfo.java +++ b/client/src/main/java/com/fastcomments/model/CommentUserHashTagInfo.java @@ -148,6 +148,50 @@ public void setRetain(@javax.annotation.Nullable Boolean retain) { this.retain = retain; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentUserHashTagInfo instance itself + */ + public CommentUserHashTagInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -162,12 +206,13 @@ public boolean equals(Object o) { return Objects.equals(this.id, commentUserHashTagInfo.id) && Objects.equals(this.tag, commentUserHashTagInfo.tag) && Objects.equals(this.url, commentUserHashTagInfo.url) && - Objects.equals(this.retain, commentUserHashTagInfo.retain); + Objects.equals(this.retain, commentUserHashTagInfo.retain)&& + Objects.equals(this.additionalProperties, commentUserHashTagInfo.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tag, url, retain); + return Objects.hash(id, tag, url, retain, additionalProperties); } @Override @@ -178,6 +223,7 @@ public String toString() { sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); sb.append(" url: ").append(toIndentedString(url)).append("\n"); sb.append(" retain: ").append(toIndentedString(retain)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -215,14 +261,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentUserHashTagInfo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentUserHashTagInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentUserHashTagInfo.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -256,6 +294,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentUserHashTagInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -263,7 +323,28 @@ public void write(JsonWriter out, CommentUserHashTagInfo value) throws IOExcepti public CommentUserHashTagInfo read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentUserHashTagInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentUserMentionInfo.java b/client/src/main/java/com/fastcomments/model/CommentUserMentionInfo.java index 2717fa28..aa68bf82 100644 --- a/client/src/main/java/com/fastcomments/model/CommentUserMentionInfo.java +++ b/client/src/main/java/com/fastcomments/model/CommentUserMentionInfo.java @@ -224,6 +224,50 @@ public void setSent(@javax.annotation.Nullable Boolean sent) { this.sent = sent; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentUserMentionInfo instance itself + */ + public CommentUserMentionInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -239,12 +283,13 @@ public boolean equals(Object o) { Objects.equals(this.tag, commentUserMentionInfo.tag) && Objects.equals(this.rawTag, commentUserMentionInfo.rawTag) && Objects.equals(this.type, commentUserMentionInfo.type) && - Objects.equals(this.sent, commentUserMentionInfo.sent); + Objects.equals(this.sent, commentUserMentionInfo.sent)&& + Objects.equals(this.additionalProperties, commentUserMentionInfo.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tag, rawTag, type, sent); + return Objects.hash(id, tag, rawTag, type, sent, additionalProperties); } @Override @@ -256,6 +301,7 @@ public String toString() { sb.append(" rawTag: ").append(toIndentedString(rawTag)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" sent: ").append(toIndentedString(sent)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -293,14 +339,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentUserMentionInfo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentUserMentionInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentUserMentionInfo.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -341,6 +379,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentUserMentionInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -348,7 +408,28 @@ public void write(JsonWriter out, CommentUserMentionInfo value) throws IOExcepti public CommentUserMentionInfo read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentUserMentionInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CommentsByIdsParams.java b/client/src/main/java/com/fastcomments/model/CommentsByIdsParams.java index b4e68671..5517cd4d 100644 --- a/client/src/main/java/com/fastcomments/model/CommentsByIdsParams.java +++ b/client/src/main/java/com/fastcomments/model/CommentsByIdsParams.java @@ -86,6 +86,50 @@ public void setIds(@javax.annotation.Nonnull List ids) { this.ids = ids; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CommentsByIdsParams instance itself + */ + public CommentsByIdsParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } CommentsByIdsParams commentsByIdsParams = (CommentsByIdsParams) o; - return Objects.equals(this.ids, commentsByIdsParams.ids); + return Objects.equals(this.ids, commentsByIdsParams.ids)&& + Objects.equals(this.additionalProperties, commentsByIdsParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(ids); + return Objects.hash(ids, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CommentsByIdsParams {\n"); sb.append(" ids: ").append(toIndentedString(ids)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentsByIdsParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentsByIdsParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentsByIdsParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -185,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentsByIdsParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -192,7 +252,28 @@ public void write(JsonWriter out, CommentsByIdsParams value) throws IOException public CommentsByIdsParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CommentsByIdsParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateAgentTenantBody.java b/client/src/main/java/com/fastcomments/model/CreateAgentTenantBody.java index a4c2717b..d258c7b5 100644 --- a/client/src/main/java/com/fastcomments/model/CreateAgentTenantBody.java +++ b/client/src/main/java/com/fastcomments/model/CreateAgentTenantBody.java @@ -134,6 +134,50 @@ public void setAgent(@javax.annotation.Nullable String agent) { this.agent = agent; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateAgentTenantBody instance itself + */ + public CreateAgentTenantBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -147,12 +191,13 @@ public boolean equals(Object o) { CreateAgentTenantBody createAgentTenantBody = (CreateAgentTenantBody) o; return Objects.equals(this.name, createAgentTenantBody.name) && Objects.equals(this.domains, createAgentTenantBody.domains) && - Objects.equals(this.agent, createAgentTenantBody.agent); + Objects.equals(this.agent, createAgentTenantBody.agent)&& + Objects.equals(this.additionalProperties, createAgentTenantBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, domains, agent); + return Objects.hash(name, domains, agent, additionalProperties); } @Override @@ -162,6 +207,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" domains: ").append(toIndentedString(domains)).append("\n"); sb.append(" agent: ").append(toIndentedString(agent)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -198,14 +244,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CreateAgentTenantBody is not found in the empty JSON string", CreateAgentTenantBody.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateAgentTenantBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateAgentTenantBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -234,6 +272,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateAgentTenantBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -241,7 +301,28 @@ public void write(JsonWriter out, CreateAgentTenantBody value) throws IOExceptio public CreateAgentTenantBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateAgentTenantBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateAgentTenantResponse.java b/client/src/main/java/com/fastcomments/model/CreateAgentTenantResponse.java index f4448e35..a6c8b5e2 100644 --- a/client/src/main/java/com/fastcomments/model/CreateAgentTenantResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreateAgentTenantResponse.java @@ -221,6 +221,50 @@ public void setMcpUrl(@javax.annotation.Nonnull String mcpUrl) { this.mcpUrl = mcpUrl; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateAgentTenantResponse instance itself + */ + public CreateAgentTenantResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -238,12 +282,13 @@ public boolean equals(Object o) { Objects.equals(this.claimUrl, createAgentTenantResponse.claimUrl) && Objects.equals(this.expiresAt, createAgentTenantResponse.expiresAt) && Objects.equals(this.apiBaseUrl, createAgentTenantResponse.apiBaseUrl) && - Objects.equals(this.mcpUrl, createAgentTenantResponse.mcpUrl); + Objects.equals(this.mcpUrl, createAgentTenantResponse.mcpUrl)&& + Objects.equals(this.additionalProperties, createAgentTenantResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, tenantId, apiKey, claimUrl, expiresAt, apiBaseUrl, mcpUrl); + return Objects.hash(status, tenantId, apiKey, claimUrl, expiresAt, apiBaseUrl, mcpUrl, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" expiresAt: ").append(toIndentedString(expiresAt)).append("\n"); sb.append(" apiBaseUrl: ").append(toIndentedString(apiBaseUrl)).append("\n"); sb.append(" mcpUrl: ").append(toIndentedString(mcpUrl)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,14 +340,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateAgentTenantResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateAgentTenantResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateAgentTenantResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -346,6 +384,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateAgentTenantResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -353,7 +413,28 @@ public void write(JsonWriter out, CreateAgentTenantResponse value) throws IOExce public CreateAgentTenantResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateAgentTenantResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateCommentParams.java b/client/src/main/java/com/fastcomments/model/CreateCommentParams.java index cb73d04b..40a5c612 100644 --- a/client/src/main/java/com/fastcomments/model/CreateCommentParams.java +++ b/client/src/main/java/com/fastcomments/model/CreateCommentParams.java @@ -988,6 +988,50 @@ public void setVotesUp(@javax.annotation.Nullable Integer votesUp) { this.votesUp = votesUp; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateCommentParams instance itself + */ + public CreateCommentParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -1035,12 +1079,13 @@ public boolean equals(Object o) { Objects.equals(this.verified, createCommentParams.verified) && Objects.equals(this.votes, createCommentParams.votes) && Objects.equals(this.votesDown, createCommentParams.votesDown) && - Objects.equals(this.votesUp, createCommentParams.votesUp); + Objects.equals(this.votesUp, createCommentParams.votesUp)&& + Objects.equals(this.additionalProperties, createCommentParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(date, localDateString, localDateHours, commenterName, commenterEmail, commenterLink, comment, productId, userId, avatarSrc, parentId, mentions, hashTags, pageTitle, isFromMyAccountPage, url, urlId, meta, moderationGroupIds, rating, fromOfflineRestore, autoplayDelayMS, feedbackIds, questionValues, poll, tos, botId, approved, domain, ip, isPinned, locale, reviewed, verified, votes, votesDown, votesUp); + return Objects.hash(date, localDateString, localDateHours, commenterName, commenterEmail, commenterLink, comment, productId, userId, avatarSrc, parentId, mentions, hashTags, pageTitle, isFromMyAccountPage, url, urlId, meta, moderationGroupIds, rating, fromOfflineRestore, autoplayDelayMS, feedbackIds, questionValues, poll, tos, botId, approved, domain, ip, isPinned, locale, reviewed, verified, votes, votesDown, votesUp, additionalProperties); } @Override @@ -1084,6 +1129,7 @@ public String toString() { sb.append(" votes: ").append(toIndentedString(votes)).append("\n"); sb.append(" votesDown: ").append(toIndentedString(votesDown)).append("\n"); sb.append(" votesUp: ").append(toIndentedString(votesUp)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -1121,14 +1167,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateCommentParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateCommentParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateCommentParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -1238,6 +1276,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateCommentParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -1245,7 +1305,28 @@ public void write(JsonWriter out, CreateCommentParams value) throws IOException public CreateCommentParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateCommentParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateEmailTemplateBody.java b/client/src/main/java/com/fastcomments/model/CreateEmailTemplateBody.java index 25254cbb..6947916f 100644 --- a/client/src/main/java/com/fastcomments/model/CreateEmailTemplateBody.java +++ b/client/src/main/java/com/fastcomments/model/CreateEmailTemplateBody.java @@ -214,6 +214,50 @@ public void setTestData(@javax.annotation.Nullable Map testData) this.testData = testData; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateEmailTemplateBody instance itself + */ + public CreateEmailTemplateBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -230,12 +274,13 @@ public boolean equals(Object o) { Objects.equals(this.ejs, createEmailTemplateBody.ejs) && Objects.equals(this.domain, createEmailTemplateBody.domain) && Objects.equals(this.translationOverridesByLocale, createEmailTemplateBody.translationOverridesByLocale) && - Objects.equals(this.testData, createEmailTemplateBody.testData); + Objects.equals(this.testData, createEmailTemplateBody.testData)&& + Objects.equals(this.additionalProperties, createEmailTemplateBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(emailTemplateId, displayName, ejs, domain, translationOverridesByLocale, testData); + return Objects.hash(emailTemplateId, displayName, ejs, domain, translationOverridesByLocale, testData, additionalProperties); } @Override @@ -248,6 +293,7 @@ public String toString() { sb.append(" domain: ").append(toIndentedString(domain)).append("\n"); sb.append(" translationOverridesByLocale: ").append(toIndentedString(translationOverridesByLocale)).append("\n"); sb.append(" testData: ").append(toIndentedString(testData)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -285,14 +331,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateEmailTemplateBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateEmailTemplateBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateEmailTemplateBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -329,6 +367,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateEmailTemplateBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -336,7 +396,28 @@ public void write(JsonWriter out, CreateEmailTemplateBody value) throws IOExcept public CreateEmailTemplateBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateEmailTemplateBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateEmailTemplateResponse.java b/client/src/main/java/com/fastcomments/model/CreateEmailTemplateResponse.java index 0b5014c6..46756583 100644 --- a/client/src/main/java/com/fastcomments/model/CreateEmailTemplateResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreateEmailTemplateResponse.java @@ -102,6 +102,50 @@ public void setEmailTemplate(@javax.annotation.Nonnull CustomEmailTemplate email this.emailTemplate = emailTemplate; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateEmailTemplateResponse instance itself + */ + public CreateEmailTemplateResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } CreateEmailTemplateResponse createEmailTemplateResponse = (CreateEmailTemplateResponse) o; return Objects.equals(this.status, createEmailTemplateResponse.status) && - Objects.equals(this.emailTemplate, createEmailTemplateResponse.emailTemplate); + Objects.equals(this.emailTemplate, createEmailTemplateResponse.emailTemplate)&& + Objects.equals(this.additionalProperties, createEmailTemplateResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, emailTemplate); + return Objects.hash(status, emailTemplate, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class CreateEmailTemplateResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" emailTemplate: ").append(toIndentedString(emailTemplate)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateEmailTemplateResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateEmailTemplateResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateEmailTemplateResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateEmailTemplateResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CreateEmailTemplateResponse value) throws IOEx public CreateEmailTemplateResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateEmailTemplateResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateFeedPostParams.java b/client/src/main/java/com/fastcomments/model/CreateFeedPostParams.java index 3dd9421a..fe1ed777 100644 --- a/client/src/main/java/com/fastcomments/model/CreateFeedPostParams.java +++ b/client/src/main/java/com/fastcomments/model/CreateFeedPostParams.java @@ -282,6 +282,50 @@ public void setMeta(@javax.annotation.Nullable Map meta) { this.meta = meta; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateFeedPostParams instance itself + */ + public CreateFeedPostParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -300,12 +344,13 @@ public boolean equals(Object o) { Objects.equals(this.fromUserId, createFeedPostParams.fromUserId) && Objects.equals(this.fromUserDisplayName, createFeedPostParams.fromUserDisplayName) && Objects.equals(this.tags, createFeedPostParams.tags) && - Objects.equals(this.meta, createFeedPostParams.meta); + Objects.equals(this.meta, createFeedPostParams.meta)&& + Objects.equals(this.additionalProperties, createFeedPostParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(title, contentHTML, media, links, fromUserId, fromUserDisplayName, tags, meta); + return Objects.hash(title, contentHTML, media, links, fromUserId, fromUserDisplayName, tags, meta, additionalProperties); } @Override @@ -320,6 +365,7 @@ public String toString() { sb.append(" fromUserDisplayName: ").append(toIndentedString(fromUserDisplayName)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -356,14 +402,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CreateFeedPostParams is not found in the empty JSON string", CreateFeedPostParams.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateFeedPostParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateFeedPostParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("title") != null && !jsonObj.get("title").isJsonNull()) && !jsonObj.get("title").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); @@ -426,6 +464,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateFeedPostParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -433,7 +493,28 @@ public void write(JsonWriter out, CreateFeedPostParams value) throws IOException public CreateFeedPostParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateFeedPostParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateFeedPostResponse.java b/client/src/main/java/com/fastcomments/model/CreateFeedPostResponse.java index af29b945..2a5e6b85 100644 --- a/client/src/main/java/com/fastcomments/model/CreateFeedPostResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreateFeedPostResponse.java @@ -102,6 +102,50 @@ public void setFeedPost(@javax.annotation.Nonnull FeedPost feedPost) { this.feedPost = feedPost; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateFeedPostResponse instance itself + */ + public CreateFeedPostResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } CreateFeedPostResponse createFeedPostResponse = (CreateFeedPostResponse) o; return Objects.equals(this.status, createFeedPostResponse.status) && - Objects.equals(this.feedPost, createFeedPostResponse.feedPost); + Objects.equals(this.feedPost, createFeedPostResponse.feedPost)&& + Objects.equals(this.additionalProperties, createFeedPostResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, feedPost); + return Objects.hash(status, feedPost, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class CreateFeedPostResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" feedPost: ").append(toIndentedString(feedPost)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateFeedPostResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateFeedPostResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateFeedPostResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateFeedPostResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CreateFeedPostResponse value) throws IOExcepti public CreateFeedPostResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateFeedPostResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateFeedPostsResponse.java b/client/src/main/java/com/fastcomments/model/CreateFeedPostsResponse.java index df23fd28..76a18735 100644 --- a/client/src/main/java/com/fastcomments/model/CreateFeedPostsResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreateFeedPostsResponse.java @@ -102,6 +102,50 @@ public void setFeedPost(@javax.annotation.Nonnull FeedPost feedPost) { this.feedPost = feedPost; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateFeedPostsResponse instance itself + */ + public CreateFeedPostsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } CreateFeedPostsResponse createFeedPostsResponse = (CreateFeedPostsResponse) o; return Objects.equals(this.status, createFeedPostsResponse.status) && - Objects.equals(this.feedPost, createFeedPostsResponse.feedPost); + Objects.equals(this.feedPost, createFeedPostsResponse.feedPost)&& + Objects.equals(this.additionalProperties, createFeedPostsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, feedPost); + return Objects.hash(status, feedPost, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class CreateFeedPostsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" feedPost: ").append(toIndentedString(feedPost)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateFeedPostsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateFeedPostsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateFeedPostsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateFeedPostsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CreateFeedPostsResponse value) throws IOExcept public CreateFeedPostsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateFeedPostsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateHashTagBody.java b/client/src/main/java/com/fastcomments/model/CreateHashTagBody.java index f9438edb..bde952f2 100644 --- a/client/src/main/java/com/fastcomments/model/CreateHashTagBody.java +++ b/client/src/main/java/com/fastcomments/model/CreateHashTagBody.java @@ -124,6 +124,50 @@ public void setUrl(@javax.annotation.Nullable String url) { this.url = url; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateHashTagBody instance itself + */ + public CreateHashTagBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -137,12 +181,13 @@ public boolean equals(Object o) { CreateHashTagBody createHashTagBody = (CreateHashTagBody) o; return Objects.equals(this.tenantId, createHashTagBody.tenantId) && Objects.equals(this.tag, createHashTagBody.tag) && - Objects.equals(this.url, createHashTagBody.url); + Objects.equals(this.url, createHashTagBody.url)&& + Objects.equals(this.additionalProperties, createHashTagBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tenantId, tag, url); + return Objects.hash(tenantId, tag, url, additionalProperties); } @Override @@ -152,6 +197,7 @@ public String toString() { sb.append(" tenantId: ").append(toIndentedString(tenantId)).append("\n"); sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -189,14 +235,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateHashTagBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateHashTagBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateHashTagBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -230,6 +268,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateHashTagBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -237,7 +297,28 @@ public void write(JsonWriter out, CreateHashTagBody value) throws IOException { public CreateHashTagBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateHashTagBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateHashTagResponse.java b/client/src/main/java/com/fastcomments/model/CreateHashTagResponse.java index 1b304810..d6b33bda 100644 --- a/client/src/main/java/com/fastcomments/model/CreateHashTagResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreateHashTagResponse.java @@ -102,6 +102,50 @@ public void setHashTag(@javax.annotation.Nonnull TenantHashTag hashTag) { this.hashTag = hashTag; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateHashTagResponse instance itself + */ + public CreateHashTagResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } CreateHashTagResponse createHashTagResponse = (CreateHashTagResponse) o; return Objects.equals(this.status, createHashTagResponse.status) && - Objects.equals(this.hashTag, createHashTagResponse.hashTag); + Objects.equals(this.hashTag, createHashTagResponse.hashTag)&& + Objects.equals(this.additionalProperties, createHashTagResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, hashTag); + return Objects.hash(status, hashTag, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class CreateHashTagResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" hashTag: ").append(toIndentedString(hashTag)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateHashTagResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateHashTagResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateHashTagResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateHashTagResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CreateHashTagResponse value) throws IOExceptio public CreateHashTagResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateHashTagResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateModeratorResponse.java b/client/src/main/java/com/fastcomments/model/CreateModeratorResponse.java index cc185ee1..237e7966 100644 --- a/client/src/main/java/com/fastcomments/model/CreateModeratorResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreateModeratorResponse.java @@ -102,6 +102,50 @@ public void setModerator(@javax.annotation.Nonnull Moderator moderator) { this.moderator = moderator; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateModeratorResponse instance itself + */ + public CreateModeratorResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } CreateModeratorResponse createModeratorResponse = (CreateModeratorResponse) o; return Objects.equals(this.status, createModeratorResponse.status) && - Objects.equals(this.moderator, createModeratorResponse.moderator); + Objects.equals(this.moderator, createModeratorResponse.moderator)&& + Objects.equals(this.additionalProperties, createModeratorResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, moderator); + return Objects.hash(status, moderator, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class CreateModeratorResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" moderator: ").append(toIndentedString(moderator)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateModeratorResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateModeratorResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateModeratorResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateModeratorResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CreateModeratorResponse value) throws IOExcept public CreateModeratorResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateModeratorResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreatePollVoteBody.java b/client/src/main/java/com/fastcomments/model/CreatePollVoteBody.java index 59972a73..efae7472 100644 --- a/client/src/main/java/com/fastcomments/model/CreatePollVoteBody.java +++ b/client/src/main/java/com/fastcomments/model/CreatePollVoteBody.java @@ -172,6 +172,50 @@ public void setIp(@javax.annotation.Nullable String ip) { this.ip = ip; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreatePollVoteBody instance itself + */ + public CreatePollVoteBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -187,12 +231,13 @@ public boolean equals(Object o) { Objects.equals(this.optionId, createPollVoteBody.optionId) && Objects.equals(this.userId, createPollVoteBody.userId) && Objects.equals(this.anonUserId, createPollVoteBody.anonUserId) && - Objects.equals(this.ip, createPollVoteBody.ip); + Objects.equals(this.ip, createPollVoteBody.ip)&& + Objects.equals(this.additionalProperties, createPollVoteBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(commentId, optionId, userId, anonUserId, ip); + return Objects.hash(commentId, optionId, userId, anonUserId, ip, additionalProperties); } @Override @@ -204,6 +249,7 @@ public String toString() { sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); sb.append(" anonUserId: ").append(toIndentedString(anonUserId)).append("\n"); sb.append(" ip: ").append(toIndentedString(ip)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -241,14 +287,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreatePollVoteBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreatePollVoteBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreatePollVoteBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -288,6 +326,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreatePollVoteBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -295,7 +355,28 @@ public void write(JsonWriter out, CreatePollVoteBody value) throws IOException { public CreatePollVoteBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreatePollVoteBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreatePollVoteResponse.java b/client/src/main/java/com/fastcomments/model/CreatePollVoteResponse.java index 6c763eb1..1415d377 100644 --- a/client/src/main/java/com/fastcomments/model/CreatePollVoteResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreatePollVoteResponse.java @@ -127,6 +127,50 @@ public void setPoll(@javax.annotation.Nonnull CommentPoll poll) { this.poll = poll; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreatePollVoteResponse instance itself + */ + public CreatePollVoteResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -140,12 +184,13 @@ public boolean equals(Object o) { CreatePollVoteResponse createPollVoteResponse = (CreatePollVoteResponse) o; return Objects.equals(this.status, createPollVoteResponse.status) && Objects.equals(this.pollVote, createPollVoteResponse.pollVote) && - Objects.equals(this.poll, createPollVoteResponse.poll); + Objects.equals(this.poll, createPollVoteResponse.poll)&& + Objects.equals(this.additionalProperties, createPollVoteResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, pollVote, poll); + return Objects.hash(status, pollVote, poll, additionalProperties); } @Override @@ -155,6 +200,7 @@ public String toString() { sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" pollVote: ").append(toIndentedString(pollVote)).append("\n"); sb.append(" poll: ").append(toIndentedString(poll)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -192,14 +238,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreatePollVoteResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreatePollVoteResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreatePollVoteResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -230,6 +268,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreatePollVoteResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -237,7 +297,28 @@ public void write(JsonWriter out, CreatePollVoteResponse value) throws IOExcepti public CreatePollVoteResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreatePollVoteResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateQuestionConfigResponse.java b/client/src/main/java/com/fastcomments/model/CreateQuestionConfigResponse.java index 66507d44..b5af00f9 100644 --- a/client/src/main/java/com/fastcomments/model/CreateQuestionConfigResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreateQuestionConfigResponse.java @@ -102,6 +102,50 @@ public void setQuestionConfig(@javax.annotation.Nonnull QuestionConfig questionC this.questionConfig = questionConfig; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateQuestionConfigResponse instance itself + */ + public CreateQuestionConfigResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } CreateQuestionConfigResponse createQuestionConfigResponse = (CreateQuestionConfigResponse) o; return Objects.equals(this.status, createQuestionConfigResponse.status) && - Objects.equals(this.questionConfig, createQuestionConfigResponse.questionConfig); + Objects.equals(this.questionConfig, createQuestionConfigResponse.questionConfig)&& + Objects.equals(this.additionalProperties, createQuestionConfigResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, questionConfig); + return Objects.hash(status, questionConfig, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class CreateQuestionConfigResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" questionConfig: ").append(toIndentedString(questionConfig)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateQuestionConfigResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateQuestionConfigResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateQuestionConfigResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateQuestionConfigResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CreateQuestionConfigResponse value) throws IOE public CreateQuestionConfigResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateQuestionConfigResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateQuestionResultResponse.java b/client/src/main/java/com/fastcomments/model/CreateQuestionResultResponse.java index a0591fc9..0acb2c50 100644 --- a/client/src/main/java/com/fastcomments/model/CreateQuestionResultResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreateQuestionResultResponse.java @@ -102,6 +102,50 @@ public void setQuestionResult(@javax.annotation.Nonnull QuestionResult questionR this.questionResult = questionResult; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateQuestionResultResponse instance itself + */ + public CreateQuestionResultResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } CreateQuestionResultResponse createQuestionResultResponse = (CreateQuestionResultResponse) o; return Objects.equals(this.status, createQuestionResultResponse.status) && - Objects.equals(this.questionResult, createQuestionResultResponse.questionResult); + Objects.equals(this.questionResult, createQuestionResultResponse.questionResult)&& + Objects.equals(this.additionalProperties, createQuestionResultResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, questionResult); + return Objects.hash(status, questionResult, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class CreateQuestionResultResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" questionResult: ").append(toIndentedString(questionResult)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateQuestionResultResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateQuestionResultResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateQuestionResultResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateQuestionResultResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CreateQuestionResultResponse value) throws IOE public CreateQuestionResultResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateQuestionResultResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateTenantBody.java b/client/src/main/java/com/fastcomments/model/CreateTenantBody.java index 58f344a0..147cc91e 100644 --- a/client/src/main/java/com/fastcomments/model/CreateTenantBody.java +++ b/client/src/main/java/com/fastcomments/model/CreateTenantBody.java @@ -602,6 +602,50 @@ public void setMeta(@javax.annotation.Nullable Map meta) { this.meta = meta; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateTenantBody instance itself + */ + public CreateTenantBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -634,12 +678,13 @@ public boolean equals(Object o) { Objects.equals(this.autoApproveCommentOnVerification, createTenantBody.autoApproveCommentOnVerification) && Objects.equals(this.sendProfaneToSpam, createTenantBody.sendProfaneToSpam) && Objects.equals(this.deAnonIpAddr, createTenantBody.deAnonIpAddr) && - Objects.equals(this.meta, createTenantBody.meta); + Objects.equals(this.meta, createTenantBody.meta)&& + Objects.equals(this.additionalProperties, createTenantBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, domainConfiguration, email, signUpDate, packageId, paymentFrequency, billingInfoValid, billingHandledExternally, isSetup, billingInfo, stripeCustomerId, stripeSubscriptionId, stripePlanId, enableProfanityFilter, enableSpamFilter, removeUnverifiedComments, unverifiedCommentsTTLms, commentsRequireApproval, autoApproveCommentOnVerification, sendProfaneToSpam, deAnonIpAddr, meta); + return Objects.hash(name, domainConfiguration, email, signUpDate, packageId, paymentFrequency, billingInfoValid, billingHandledExternally, isSetup, billingInfo, stripeCustomerId, stripeSubscriptionId, stripePlanId, enableProfanityFilter, enableSpamFilter, removeUnverifiedComments, unverifiedCommentsTTLms, commentsRequireApproval, autoApproveCommentOnVerification, sendProfaneToSpam, deAnonIpAddr, meta, additionalProperties); } @Override @@ -668,6 +713,7 @@ public String toString() { sb.append(" sendProfaneToSpam: ").append(toIndentedString(sendProfaneToSpam)).append("\n"); sb.append(" deAnonIpAddr: ").append(toIndentedString(deAnonIpAddr)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -705,14 +751,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateTenantBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateTenantBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateTenantBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -769,6 +807,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateTenantBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -776,7 +836,28 @@ public void write(JsonWriter out, CreateTenantBody value) throws IOException { public CreateTenantBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateTenantBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateTenantPackageBody.java b/client/src/main/java/com/fastcomments/model/CreateTenantPackageBody.java index 1cc9fb1a..5f683585 100644 --- a/client/src/main/java/com/fastcomments/model/CreateTenantPackageBody.java +++ b/client/src/main/java/com/fastcomments/model/CreateTenantPackageBody.java @@ -1238,6 +1238,50 @@ public void setFlexSSOModeratorUnit(@javax.annotation.Nullable Double flexSSOMod this.flexSSOModeratorUnit = flexSSOModeratorUnit; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateTenantPackageBody instance itself + */ + public CreateTenantPackageBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -1297,12 +1341,13 @@ public boolean equals(Object o) { Objects.equals(this.flexSSOAdminCostCents, createTenantPackageBody.flexSSOAdminCostCents) && Objects.equals(this.flexSSOAdminUnit, createTenantPackageBody.flexSSOAdminUnit) && Objects.equals(this.flexSSOModeratorCostCents, createTenantPackageBody.flexSSOModeratorCostCents) && - Objects.equals(this.flexSSOModeratorUnit, createTenantPackageBody.flexSSOModeratorUnit); + Objects.equals(this.flexSSOModeratorUnit, createTenantPackageBody.flexSSOModeratorUnit)&& + Objects.equals(this.additionalProperties, createTenantPackageBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, monthlyCostUSD, yearlyCostUSD, monthlyStripePlanId, yearlyStripePlanId, maxMonthlyPageLoads, maxMonthlyAPICredits, maxMonthlySmallWidgetsCredits, maxMonthlyComments, maxConcurrentUsers, maxTenantUsers, maxSSOUsers, maxModerators, maxDomains, maxWhiteLabeledTenants, maxMonthlyEventLogRequests, maxCustomCollectionSize, hasWhiteLabeling, hasDebranding, hasLLMSpamDetection, forWhoText, featureTaglines, hasAuditing, hasFlexPricing, enableSAML, flexPageLoadCostCents, flexPageLoadUnit, flexCommentCostCents, flexCommentUnit, flexSSOUserCostCents, flexSSOUserUnit, flexAPICreditCostCents, flexAPICreditUnit, flexSmallWidgetsCreditCostCents, flexSmallWidgetsCreditUnit, flexModeratorCostCents, flexModeratorUnit, flexAdminCostCents, flexAdminUnit, flexDomainCostCents, flexDomainUnit, flexLLMCostCents, flexLLMUnit, flexMinimumCostCents, flexManagedTenantCostCents, flexSSOAdminCostCents, flexSSOAdminUnit, flexSSOModeratorCostCents, flexSSOModeratorUnit); + return Objects.hash(name, monthlyCostUSD, yearlyCostUSD, monthlyStripePlanId, yearlyStripePlanId, maxMonthlyPageLoads, maxMonthlyAPICredits, maxMonthlySmallWidgetsCredits, maxMonthlyComments, maxConcurrentUsers, maxTenantUsers, maxSSOUsers, maxModerators, maxDomains, maxWhiteLabeledTenants, maxMonthlyEventLogRequests, maxCustomCollectionSize, hasWhiteLabeling, hasDebranding, hasLLMSpamDetection, forWhoText, featureTaglines, hasAuditing, hasFlexPricing, enableSAML, flexPageLoadCostCents, flexPageLoadUnit, flexCommentCostCents, flexCommentUnit, flexSSOUserCostCents, flexSSOUserUnit, flexAPICreditCostCents, flexAPICreditUnit, flexSmallWidgetsCreditCostCents, flexSmallWidgetsCreditUnit, flexModeratorCostCents, flexModeratorUnit, flexAdminCostCents, flexAdminUnit, flexDomainCostCents, flexDomainUnit, flexLLMCostCents, flexLLMUnit, flexMinimumCostCents, flexManagedTenantCostCents, flexSSOAdminCostCents, flexSSOAdminUnit, flexSSOModeratorCostCents, flexSSOModeratorUnit, additionalProperties); } @Override @@ -1358,6 +1403,7 @@ public String toString() { sb.append(" flexSSOAdminUnit: ").append(toIndentedString(flexSSOAdminUnit)).append("\n"); sb.append(" flexSSOModeratorCostCents: ").append(toIndentedString(flexSSOModeratorCostCents)).append("\n"); sb.append(" flexSSOModeratorUnit: ").append(toIndentedString(flexSSOModeratorUnit)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -1395,14 +1441,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateTenantPackageBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateTenantPackageBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateTenantPackageBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -1445,6 +1483,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateTenantPackageBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -1452,7 +1512,28 @@ public void write(JsonWriter out, CreateTenantPackageBody value) throws IOExcept public CreateTenantPackageBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateTenantPackageBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateTenantPackageResponse.java b/client/src/main/java/com/fastcomments/model/CreateTenantPackageResponse.java index a5e9c70d..f6a8eecc 100644 --- a/client/src/main/java/com/fastcomments/model/CreateTenantPackageResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreateTenantPackageResponse.java @@ -102,6 +102,50 @@ public void setTenantPackage(@javax.annotation.Nonnull TenantPackage tenantPacka this.tenantPackage = tenantPackage; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateTenantPackageResponse instance itself + */ + public CreateTenantPackageResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } CreateTenantPackageResponse createTenantPackageResponse = (CreateTenantPackageResponse) o; return Objects.equals(this.status, createTenantPackageResponse.status) && - Objects.equals(this.tenantPackage, createTenantPackageResponse.tenantPackage); + Objects.equals(this.tenantPackage, createTenantPackageResponse.tenantPackage)&& + Objects.equals(this.additionalProperties, createTenantPackageResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, tenantPackage); + return Objects.hash(status, tenantPackage, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class CreateTenantPackageResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" tenantPackage: ").append(toIndentedString(tenantPackage)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateTenantPackageResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateTenantPackageResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateTenantPackageResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateTenantPackageResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CreateTenantPackageResponse value) throws IOEx public CreateTenantPackageResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateTenantPackageResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateTenantResponse.java b/client/src/main/java/com/fastcomments/model/CreateTenantResponse.java index b5730387..7242bca1 100644 --- a/client/src/main/java/com/fastcomments/model/CreateTenantResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreateTenantResponse.java @@ -102,6 +102,50 @@ public void setTenant(@javax.annotation.Nonnull APITenant tenant) { this.tenant = tenant; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateTenantResponse instance itself + */ + public CreateTenantResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } CreateTenantResponse createTenantResponse = (CreateTenantResponse) o; return Objects.equals(this.status, createTenantResponse.status) && - Objects.equals(this.tenant, createTenantResponse.tenant); + Objects.equals(this.tenant, createTenantResponse.tenant)&& + Objects.equals(this.additionalProperties, createTenantResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, tenant); + return Objects.hash(status, tenant, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class CreateTenantResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" tenant: ").append(toIndentedString(tenant)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateTenantResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateTenantResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateTenantResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateTenantResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CreateTenantResponse value) throws IOException public CreateTenantResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateTenantResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateTenantUserBody.java b/client/src/main/java/com/fastcomments/model/CreateTenantUserBody.java index 734e605f..50e7720b 100644 --- a/client/src/main/java/com/fastcomments/model/CreateTenantUserBody.java +++ b/client/src/main/java/com/fastcomments/model/CreateTenantUserBody.java @@ -638,6 +638,50 @@ public void setDisplayLabel(@javax.annotation.Nullable String displayLabel) { this.displayLabel = displayLabel; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateTenantUserBody instance itself + */ + public CreateTenantUserBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -672,12 +716,13 @@ public boolean equals(Object o) { Objects.equals(this.isAPIAdmin, createTenantUserBody.isAPIAdmin) && Objects.equals(this.moderatorIds, createTenantUserBody.moderatorIds) && Objects.equals(this.digestEmailFrequency, createTenantUserBody.digestEmailFrequency) && - Objects.equals(this.displayLabel, createTenantUserBody.displayLabel); + Objects.equals(this.displayLabel, createTenantUserBody.displayLabel)&& + Objects.equals(this.additionalProperties, createTenantUserBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(username, email, displayName, websiteUrl, signUpDate, locale, verified, loginCount, optedInNotifications, optedInTenantNotifications, hideAccountCode, avatarSrc, isHelpRequestAdmin, isAccountOwner, isAdminAdmin, isBillingAdmin, isAnalyticsAdmin, isCustomizationAdmin, isManageDataAdmin, isCommentModeratorAdmin, isAPIAdmin, moderatorIds, digestEmailFrequency, displayLabel); + return Objects.hash(username, email, displayName, websiteUrl, signUpDate, locale, verified, loginCount, optedInNotifications, optedInTenantNotifications, hideAccountCode, avatarSrc, isHelpRequestAdmin, isAccountOwner, isAdminAdmin, isBillingAdmin, isAnalyticsAdmin, isCustomizationAdmin, isManageDataAdmin, isCommentModeratorAdmin, isAPIAdmin, moderatorIds, digestEmailFrequency, displayLabel, additionalProperties); } @Override @@ -708,6 +753,7 @@ public String toString() { sb.append(" moderatorIds: ").append(toIndentedString(moderatorIds)).append("\n"); sb.append(" digestEmailFrequency: ").append(toIndentedString(digestEmailFrequency)).append("\n"); sb.append(" displayLabel: ").append(toIndentedString(displayLabel)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -745,14 +791,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateTenantUserBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateTenantUserBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateTenantUserBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -802,6 +840,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateTenantUserBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -809,7 +869,28 @@ public void write(JsonWriter out, CreateTenantUserBody value) throws IOException public CreateTenantUserBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateTenantUserBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateTenantUserResponse.java b/client/src/main/java/com/fastcomments/model/CreateTenantUserResponse.java index fdde7ddd..192dd6e4 100644 --- a/client/src/main/java/com/fastcomments/model/CreateTenantUserResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreateTenantUserResponse.java @@ -102,6 +102,50 @@ public void setTenantUser(@javax.annotation.Nonnull User tenantUser) { this.tenantUser = tenantUser; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateTenantUserResponse instance itself + */ + public CreateTenantUserResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } CreateTenantUserResponse createTenantUserResponse = (CreateTenantUserResponse) o; return Objects.equals(this.status, createTenantUserResponse.status) && - Objects.equals(this.tenantUser, createTenantUserResponse.tenantUser); + Objects.equals(this.tenantUser, createTenantUserResponse.tenantUser)&& + Objects.equals(this.additionalProperties, createTenantUserResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, tenantUser); + return Objects.hash(status, tenantUser, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class CreateTenantUserResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" tenantUser: ").append(toIndentedString(tenantUser)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateTenantUserResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateTenantUserResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateTenantUserResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateTenantUserResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CreateTenantUserResponse value) throws IOExcep public CreateTenantUserResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateTenantUserResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateTicketBody.java b/client/src/main/java/com/fastcomments/model/CreateTicketBody.java index 2fbce0df..8a56744d 100644 --- a/client/src/main/java/com/fastcomments/model/CreateTicketBody.java +++ b/client/src/main/java/com/fastcomments/model/CreateTicketBody.java @@ -76,6 +76,50 @@ public void setSubject(@javax.annotation.Nonnull String subject) { this.subject = subject; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateTicketBody instance itself + */ + public CreateTicketBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -87,12 +131,13 @@ public boolean equals(Object o) { return false; } CreateTicketBody createTicketBody = (CreateTicketBody) o; - return Objects.equals(this.subject, createTicketBody.subject); + return Objects.equals(this.subject, createTicketBody.subject)&& + Objects.equals(this.additionalProperties, createTicketBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(subject); + return Objects.hash(subject, additionalProperties); } @Override @@ -100,6 +145,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CreateTicketBody {\n"); sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -137,14 +183,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateTicketBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateTicketBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateTicketBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -172,6 +210,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateTicketBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -179,7 +239,28 @@ public void write(JsonWriter out, CreateTicketBody value) throws IOException { public CreateTicketBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateTicketBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateTicketResponse.java b/client/src/main/java/com/fastcomments/model/CreateTicketResponse.java index bee53254..996d3c34 100644 --- a/client/src/main/java/com/fastcomments/model/CreateTicketResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreateTicketResponse.java @@ -102,6 +102,50 @@ public void setTicket(@javax.annotation.Nonnull APITicket ticket) { this.ticket = ticket; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateTicketResponse instance itself + */ + public CreateTicketResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } CreateTicketResponse createTicketResponse = (CreateTicketResponse) o; return Objects.equals(this.status, createTicketResponse.status) && - Objects.equals(this.ticket, createTicketResponse.ticket); + Objects.equals(this.ticket, createTicketResponse.ticket)&& + Objects.equals(this.additionalProperties, createTicketResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, ticket); + return Objects.hash(status, ticket, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class CreateTicketResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" ticket: ").append(toIndentedString(ticket)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateTicketResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateTicketResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateTicketResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateTicketResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CreateTicketResponse value) throws IOException public CreateTicketResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateTicketResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateUserBadgeParams.java b/client/src/main/java/com/fastcomments/model/CreateUserBadgeParams.java index 34a52dae..1dad9228 100644 --- a/client/src/main/java/com/fastcomments/model/CreateUserBadgeParams.java +++ b/client/src/main/java/com/fastcomments/model/CreateUserBadgeParams.java @@ -124,6 +124,50 @@ public void setDisplayedOnComments(@javax.annotation.Nullable Boolean displayedO this.displayedOnComments = displayedOnComments; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateUserBadgeParams instance itself + */ + public CreateUserBadgeParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -137,12 +181,13 @@ public boolean equals(Object o) { CreateUserBadgeParams createUserBadgeParams = (CreateUserBadgeParams) o; return Objects.equals(this.userId, createUserBadgeParams.userId) && Objects.equals(this.badgeId, createUserBadgeParams.badgeId) && - Objects.equals(this.displayedOnComments, createUserBadgeParams.displayedOnComments); + Objects.equals(this.displayedOnComments, createUserBadgeParams.displayedOnComments)&& + Objects.equals(this.additionalProperties, createUserBadgeParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(userId, badgeId, displayedOnComments); + return Objects.hash(userId, badgeId, displayedOnComments, additionalProperties); } @Override @@ -152,6 +197,7 @@ public String toString() { sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); sb.append(" badgeId: ").append(toIndentedString(badgeId)).append("\n"); sb.append(" displayedOnComments: ").append(toIndentedString(displayedOnComments)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -189,14 +235,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateUserBadgeParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateUserBadgeParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateUserBadgeParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -227,6 +265,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateUserBadgeParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -234,7 +294,28 @@ public void write(JsonWriter out, CreateUserBadgeParams value) throws IOExceptio public CreateUserBadgeParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateUserBadgeParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateWebhookParams.java b/client/src/main/java/com/fastcomments/model/CreateWebhookParams.java index a4e729f3..9b849391 100644 --- a/client/src/main/java/com/fastcomments/model/CreateWebhookParams.java +++ b/client/src/main/java/com/fastcomments/model/CreateWebhookParams.java @@ -150,6 +150,50 @@ public void setMethod(@javax.annotation.Nullable WebhookHTTPMethod method) { this.method = method; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateWebhookParams instance itself + */ + public CreateWebhookParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -164,12 +208,13 @@ public boolean equals(Object o) { return Objects.equals(this.url, createWebhookParams.url) && Objects.equals(this.event, createWebhookParams.event) && Objects.equals(this.domain, createWebhookParams.domain) && - Objects.equals(this.method, createWebhookParams.method); + Objects.equals(this.method, createWebhookParams.method)&& + Objects.equals(this.additionalProperties, createWebhookParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(url, event, domain, method); + return Objects.hash(url, event, domain, method, additionalProperties); } @Override @@ -180,6 +225,7 @@ public String toString() { sb.append(" event: ").append(toIndentedString(event)).append("\n"); sb.append(" domain: ").append(toIndentedString(domain)).append("\n"); sb.append(" method: ").append(toIndentedString(method)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -217,14 +263,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateWebhookParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateWebhookParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateWebhookParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -261,6 +299,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateWebhookParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -268,7 +328,28 @@ public void write(JsonWriter out, CreateWebhookParams value) throws IOException public CreateWebhookParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateWebhookParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CreateWebhookResponse.java b/client/src/main/java/com/fastcomments/model/CreateWebhookResponse.java index 10b56bdb..be3155c9 100644 --- a/client/src/main/java/com/fastcomments/model/CreateWebhookResponse.java +++ b/client/src/main/java/com/fastcomments/model/CreateWebhookResponse.java @@ -102,6 +102,50 @@ public void setWebhook(@javax.annotation.Nonnull PublicWebhook webhook) { this.webhook = webhook; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateWebhookResponse instance itself + */ + public CreateWebhookResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } CreateWebhookResponse createWebhookResponse = (CreateWebhookResponse) o; return Objects.equals(this.status, createWebhookResponse.status) && - Objects.equals(this.webhook, createWebhookResponse.webhook); + Objects.equals(this.webhook, createWebhookResponse.webhook)&& + Objects.equals(this.additionalProperties, createWebhookResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, webhook); + return Objects.hash(status, webhook, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class CreateWebhookResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" webhook: ").append(toIndentedString(webhook)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateWebhookResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CreateWebhookResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateWebhookResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CreateWebhookResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, CreateWebhookResponse value) throws IOExceptio public CreateWebhookResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateWebhookResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CustomConfigParameters.java b/client/src/main/java/com/fastcomments/model/CustomConfigParameters.java index fdf6ce77..610adef5 100644 --- a/client/src/main/java/com/fastcomments/model/CustomConfigParameters.java +++ b/client/src/main/java/com/fastcomments/model/CustomConfigParameters.java @@ -104,11 +104,21 @@ public class CustomConfigParameters { @javax.annotation.Nullable private List allowedLanguages; + public static final String SERIALIZED_NAME_ALLOW_SIMPLE_S_S_O_ADMINS = "allowSimpleSSOAdmins"; + @SerializedName(SERIALIZED_NAME_ALLOW_SIMPLE_S_S_O_ADMINS) + @javax.annotation.Nullable + private Boolean allowSimpleSSOAdmins; + public static final String SERIALIZED_NAME_AUTO_GENERATE_USERNAME = "autoGenerateUsername"; @SerializedName(SERIALIZED_NAME_AUTO_GENERATE_USERNAME) @javax.annotation.Nullable private Boolean autoGenerateUsername; + public static final String SERIALIZED_NAME_AUTO_VERIFY_SIMPLE_S_S_O_COMMENTS = "autoVerifySimpleSSOComments"; + @SerializedName(SERIALIZED_NAME_AUTO_VERIFY_SIMPLE_S_S_O_COMMENTS) + @javax.annotation.Nullable + private Boolean autoVerifySimpleSSOComments; + public static final String SERIALIZED_NAME_COLLAPSE_REPLIES = "collapseReplies"; @SerializedName(SERIALIZED_NAME_COLLAPSE_REPLIES) @javax.annotation.Nullable @@ -664,6 +674,25 @@ public void setAllowedLanguages(@javax.annotation.Nullable List allowedL } + public CustomConfigParameters allowSimpleSSOAdmins(@javax.annotation.Nullable Boolean allowSimpleSSOAdmins) { + this.allowSimpleSSOAdmins = allowSimpleSSOAdmins; + return this; + } + + /** + * Simple SSO users on this page or domain can be admins and moderators: they keep those flags and pick them up from a matching email. + * @return allowSimpleSSOAdmins + */ + @javax.annotation.Nullable + public Boolean getAllowSimpleSSOAdmins() { + return allowSimpleSSOAdmins; + } + + public void setAllowSimpleSSOAdmins(@javax.annotation.Nullable Boolean allowSimpleSSOAdmins) { + this.allowSimpleSSOAdmins = allowSimpleSSOAdmins; + } + + public CustomConfigParameters autoGenerateUsername(@javax.annotation.Nullable Boolean autoGenerateUsername) { this.autoGenerateUsername = autoGenerateUsername; return this; @@ -683,6 +712,25 @@ public void setAutoGenerateUsername(@javax.annotation.Nullable Boolean autoGener } + public CustomConfigParameters autoVerifySimpleSSOComments(@javax.annotation.Nullable Boolean autoVerifySimpleSSOComments) { + this.autoVerifySimpleSSOComments = autoVerifySimpleSSOComments; + return this; + } + + /** + * Comments from Simple SSO users on this page or domain are verified right away, instead of through an emailed link. + * @return autoVerifySimpleSSOComments + */ + @javax.annotation.Nullable + public Boolean getAutoVerifySimpleSSOComments() { + return autoVerifySimpleSSOComments; + } + + public void setAutoVerifySimpleSSOComments(@javax.annotation.Nullable Boolean autoVerifySimpleSSOComments) { + this.autoVerifySimpleSSOComments = autoVerifySimpleSSOComments; + } + + public CustomConfigParameters collapseReplies(@javax.annotation.Nullable Boolean collapseReplies) { this.collapseReplies = collapseReplies; return this; @@ -2356,6 +2404,50 @@ public void setCommentTranslation(@javax.annotation.Nullable CommentTranslationM this.commentTranslation = commentTranslation; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CustomConfigParameters instance itself + */ + public CustomConfigParameters putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -2373,7 +2465,9 @@ public boolean equals(Object o) { Objects.equals(this.allowAnonFlag, customConfigParameters.allowAnonFlag) && Objects.equals(this.allowAnonVotes, customConfigParameters.allowAnonVotes) && Objects.equals(this.allowedLanguages, customConfigParameters.allowedLanguages) && + Objects.equals(this.allowSimpleSSOAdmins, customConfigParameters.allowSimpleSSOAdmins) && Objects.equals(this.autoGenerateUsername, customConfigParameters.autoGenerateUsername) && + Objects.equals(this.autoVerifySimpleSSOComments, customConfigParameters.autoVerifySimpleSSOComments) && Objects.equals(this.collapseReplies, customConfigParameters.collapseReplies) && Objects.equals(this.commentCountFormat, customConfigParameters.commentCountFormat) && Objects.equals(this.commentHTMLRenderingMode, customConfigParameters.commentHTMLRenderingMode) && @@ -2459,12 +2553,13 @@ public boolean equals(Object o) { Objects.equals(this.ticketMaxFileSize, customConfigParameters.ticketMaxFileSize) && Objects.equals(this.ticketAutoAssignUserIds, customConfigParameters.ticketAutoAssignUserIds) && Objects.equals(this.tos, customConfigParameters.tos) && - Objects.equals(this.commentTranslation, customConfigParameters.commentTranslation); + Objects.equals(this.commentTranslation, customConfigParameters.commentTranslation)&& + Objects.equals(this.additionalProperties, customConfigParameters.additionalProperties); } @Override public int hashCode() { - return Objects.hash(absoluteAndRelativeDates, absoluteDates, allowAnon, allowAnonFlag, allowAnonVotes, allowedLanguages, autoGenerateUsername, collapseReplies, commentCountFormat, commentHTMLRenderingMode, commentsRequireApproval, commentThreadDeleteMode, pollCreation, pollVoting, commenterNameFormat, countAboveToggle, customCSS, defaultAvatarSrc, defaultSortDirection, defaultUsername, disableAutoAdminMigration, disableAutoHashTagCreation, disableBlocking, disableCommenterCommentDelete, disableCommenterCommentEdit, disableEmailInputs, disableLiveCommenting, disableNotificationBell, disableProfileComments, disableProfileDirectMessages, disableProfiles, disableSuccessMessage, disableToolbar, disableUnverifiedLabel, disableVoting, enableCommenterLinks, enableSearch, enableSpoilers, enableThirdPartyCookieBypass, enableViewCounts, enableVoteList, enableWYSIWYG, gifRating, hasDarkBackground, headerHTML, hideAvatars, hideCommentsUnderCountTextFormat, imageContentProfanityLevel, inputAfterComments, limitCommentsByGroups, locale, maxCommentCharacterLength, maxCommentCreatedCountPUPM, noCustomConfig, mentionAutoCompleteMode, noImageUploads, allowEmbeds, allowedEmbedDomains, noStyles, pageSize, readonly, noNewRootComments, requireSSO, enableFChat, enableResizeHandle, restrictedLinkDomains, showBadgesInTopBar, showCommentSaveSuccess, showLiveRightAway, showQuestion, spamRules, ssoSecLvl, translations, useShowCommentsToggle, useSingleLineCommentInput, voteStyle, widgetQuestionId, widgetQuestionResultsStyle, widgetQuestionShowBreakdown, widgetQuestionStyle, widgetQuestionWhenToSave, widgetQuestionsRequired, widgetSubQuestionVisibility, wrap, usersListLocation, usersListIncludeOffline, ticketBaseUrl, ticketKBSearchEndpoint, ticketFileUploadsEnabled, ticketMaxFileSize, ticketAutoAssignUserIds, tos, commentTranslation); + return Objects.hash(absoluteAndRelativeDates, absoluteDates, allowAnon, allowAnonFlag, allowAnonVotes, allowedLanguages, allowSimpleSSOAdmins, autoGenerateUsername, autoVerifySimpleSSOComments, collapseReplies, commentCountFormat, commentHTMLRenderingMode, commentsRequireApproval, commentThreadDeleteMode, pollCreation, pollVoting, commenterNameFormat, countAboveToggle, customCSS, defaultAvatarSrc, defaultSortDirection, defaultUsername, disableAutoAdminMigration, disableAutoHashTagCreation, disableBlocking, disableCommenterCommentDelete, disableCommenterCommentEdit, disableEmailInputs, disableLiveCommenting, disableNotificationBell, disableProfileComments, disableProfileDirectMessages, disableProfiles, disableSuccessMessage, disableToolbar, disableUnverifiedLabel, disableVoting, enableCommenterLinks, enableSearch, enableSpoilers, enableThirdPartyCookieBypass, enableViewCounts, enableVoteList, enableWYSIWYG, gifRating, hasDarkBackground, headerHTML, hideAvatars, hideCommentsUnderCountTextFormat, imageContentProfanityLevel, inputAfterComments, limitCommentsByGroups, locale, maxCommentCharacterLength, maxCommentCreatedCountPUPM, noCustomConfig, mentionAutoCompleteMode, noImageUploads, allowEmbeds, allowedEmbedDomains, noStyles, pageSize, readonly, noNewRootComments, requireSSO, enableFChat, enableResizeHandle, restrictedLinkDomains, showBadgesInTopBar, showCommentSaveSuccess, showLiveRightAway, showQuestion, spamRules, ssoSecLvl, translations, useShowCommentsToggle, useSingleLineCommentInput, voteStyle, widgetQuestionId, widgetQuestionResultsStyle, widgetQuestionShowBreakdown, widgetQuestionStyle, widgetQuestionWhenToSave, widgetQuestionsRequired, widgetSubQuestionVisibility, wrap, usersListLocation, usersListIncludeOffline, ticketBaseUrl, ticketKBSearchEndpoint, ticketFileUploadsEnabled, ticketMaxFileSize, ticketAutoAssignUserIds, tos, commentTranslation, additionalProperties); } @Override @@ -2477,7 +2572,9 @@ public String toString() { sb.append(" allowAnonFlag: ").append(toIndentedString(allowAnonFlag)).append("\n"); sb.append(" allowAnonVotes: ").append(toIndentedString(allowAnonVotes)).append("\n"); sb.append(" allowedLanguages: ").append(toIndentedString(allowedLanguages)).append("\n"); + sb.append(" allowSimpleSSOAdmins: ").append(toIndentedString(allowSimpleSSOAdmins)).append("\n"); sb.append(" autoGenerateUsername: ").append(toIndentedString(autoGenerateUsername)).append("\n"); + sb.append(" autoVerifySimpleSSOComments: ").append(toIndentedString(autoVerifySimpleSSOComments)).append("\n"); sb.append(" collapseReplies: ").append(toIndentedString(collapseReplies)).append("\n"); sb.append(" commentCountFormat: ").append(toIndentedString(commentCountFormat)).append("\n"); sb.append(" commentHTMLRenderingMode: ").append(toIndentedString(commentHTMLRenderingMode)).append("\n"); @@ -2564,6 +2661,7 @@ public String toString() { sb.append(" ticketAutoAssignUserIds: ").append(toIndentedString(ticketAutoAssignUserIds)).append("\n"); sb.append(" tos: ").append(toIndentedString(tos)).append("\n"); sb.append(" commentTranslation: ").append(toIndentedString(commentTranslation)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -2582,7 +2680,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("absoluteAndRelativeDates", "absoluteDates", "allowAnon", "allowAnonFlag", "allowAnonVotes", "allowedLanguages", "autoGenerateUsername", "collapseReplies", "commentCountFormat", "commentHTMLRenderingMode", "commentsRequireApproval", "commentThreadDeleteMode", "pollCreation", "pollVoting", "commenterNameFormat", "countAboveToggle", "customCSS", "defaultAvatarSrc", "defaultSortDirection", "defaultUsername", "disableAutoAdminMigration", "disableAutoHashTagCreation", "disableBlocking", "disableCommenterCommentDelete", "disableCommenterCommentEdit", "disableEmailInputs", "disableLiveCommenting", "disableNotificationBell", "disableProfileComments", "disableProfileDirectMessages", "disableProfiles", "disableSuccessMessage", "disableToolbar", "disableUnverifiedLabel", "disableVoting", "enableCommenterLinks", "enableSearch", "enableSpoilers", "enableThirdPartyCookieBypass", "enableViewCounts", "enableVoteList", "enableWYSIWYG", "gifRating", "hasDarkBackground", "headerHTML", "hideAvatars", "hideCommentsUnderCountTextFormat", "imageContentProfanityLevel", "inputAfterComments", "limitCommentsByGroups", "locale", "maxCommentCharacterLength", "maxCommentCreatedCountPUPM", "noCustomConfig", "mentionAutoCompleteMode", "noImageUploads", "allowEmbeds", "allowedEmbedDomains", "noStyles", "pageSize", "readonly", "noNewRootComments", "requireSSO", "enableFChat", "enableResizeHandle", "restrictedLinkDomains", "showBadgesInTopBar", "showCommentSaveSuccess", "showLiveRightAway", "showQuestion", "spamRules", "ssoSecLvl", "translations", "useShowCommentsToggle", "useSingleLineCommentInput", "voteStyle", "widgetQuestionId", "widgetQuestionResultsStyle", "widgetQuestionShowBreakdown", "widgetQuestionStyle", "widgetQuestionWhenToSave", "widgetQuestionsRequired", "widgetSubQuestionVisibility", "wrap", "usersListLocation", "usersListIncludeOffline", "ticketBaseUrl", "ticketKBSearchEndpoint", "ticketFileUploadsEnabled", "ticketMaxFileSize", "ticketAutoAssignUserIds", "tos", "commentTranslation")); + openapiFields = new HashSet(Arrays.asList("absoluteAndRelativeDates", "absoluteDates", "allowAnon", "allowAnonFlag", "allowAnonVotes", "allowedLanguages", "allowSimpleSSOAdmins", "autoGenerateUsername", "autoVerifySimpleSSOComments", "collapseReplies", "commentCountFormat", "commentHTMLRenderingMode", "commentsRequireApproval", "commentThreadDeleteMode", "pollCreation", "pollVoting", "commenterNameFormat", "countAboveToggle", "customCSS", "defaultAvatarSrc", "defaultSortDirection", "defaultUsername", "disableAutoAdminMigration", "disableAutoHashTagCreation", "disableBlocking", "disableCommenterCommentDelete", "disableCommenterCommentEdit", "disableEmailInputs", "disableLiveCommenting", "disableNotificationBell", "disableProfileComments", "disableProfileDirectMessages", "disableProfiles", "disableSuccessMessage", "disableToolbar", "disableUnverifiedLabel", "disableVoting", "enableCommenterLinks", "enableSearch", "enableSpoilers", "enableThirdPartyCookieBypass", "enableViewCounts", "enableVoteList", "enableWYSIWYG", "gifRating", "hasDarkBackground", "headerHTML", "hideAvatars", "hideCommentsUnderCountTextFormat", "imageContentProfanityLevel", "inputAfterComments", "limitCommentsByGroups", "locale", "maxCommentCharacterLength", "maxCommentCreatedCountPUPM", "noCustomConfig", "mentionAutoCompleteMode", "noImageUploads", "allowEmbeds", "allowedEmbedDomains", "noStyles", "pageSize", "readonly", "noNewRootComments", "requireSSO", "enableFChat", "enableResizeHandle", "restrictedLinkDomains", "showBadgesInTopBar", "showCommentSaveSuccess", "showLiveRightAway", "showQuestion", "spamRules", "ssoSecLvl", "translations", "useShowCommentsToggle", "useSingleLineCommentInput", "voteStyle", "widgetQuestionId", "widgetQuestionResultsStyle", "widgetQuestionShowBreakdown", "widgetQuestionStyle", "widgetQuestionWhenToSave", "widgetQuestionsRequired", "widgetSubQuestionVisibility", "wrap", "usersListLocation", "usersListIncludeOffline", "ticketBaseUrl", "ticketKBSearchEndpoint", "ticketFileUploadsEnabled", "ticketMaxFileSize", "ticketAutoAssignUserIds", "tos", "commentTranslation")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(0); @@ -2600,14 +2698,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in CustomConfigParameters is not found in the empty JSON string", CustomConfigParameters.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CustomConfigParameters.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CustomConfigParameters` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("allowedLanguages") != null && !jsonObj.get("allowedLanguages").isJsonNull() && !jsonObj.get("allowedLanguages").isJsonArray()) { @@ -2762,6 +2852,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CustomConfigParameters value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -2769,7 +2881,28 @@ public void write(JsonWriter out, CustomConfigParameters value) throws IOExcepti public CustomConfigParameters read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CustomConfigParameters instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/CustomEmailTemplate.java b/client/src/main/java/com/fastcomments/model/CustomEmailTemplate.java index 1d0d2052..9e6dabde 100644 --- a/client/src/main/java/com/fastcomments/model/CustomEmailTemplate.java +++ b/client/src/main/java/com/fastcomments/model/CustomEmailTemplate.java @@ -327,6 +327,50 @@ public void setTestData(@javax.annotation.Nullable Object testData) { this.testData = testData; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CustomEmailTemplate instance itself + */ + public CustomEmailTemplate putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -348,12 +392,13 @@ public boolean equals(Object o) { Objects.equals(this.domain, customEmailTemplate.domain) && Objects.equals(this.ejs, customEmailTemplate.ejs) && Objects.equals(this.translationOverridesByLocale, customEmailTemplate.translationOverridesByLocale) && - Objects.equals(this.testData, customEmailTemplate.testData); + Objects.equals(this.testData, customEmailTemplate.testData)&& + Objects.equals(this.additionalProperties, customEmailTemplate.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, emailTemplateId, displayName, createdAt, updatedAt, updatedByUserId, domain, ejs, translationOverridesByLocale, testData); + return Objects.hash(id, tenantId, emailTemplateId, displayName, createdAt, updatedAt, updatedByUserId, domain, ejs, translationOverridesByLocale, testData, additionalProperties); } @Override @@ -371,6 +416,7 @@ public String toString() { sb.append(" ejs: ").append(toIndentedString(ejs)).append("\n"); sb.append(" translationOverridesByLocale: ").append(toIndentedString(translationOverridesByLocale)).append("\n"); sb.append(" testData: ").append(toIndentedString(testData)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -408,14 +454,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CustomEmailTemplate.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CustomEmailTemplate` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CustomEmailTemplate.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -461,6 +499,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CustomEmailTemplate value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -468,7 +528,28 @@ public void write(JsonWriter out, CustomEmailTemplate value) throws IOException public CustomEmailTemplate read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CustomEmailTemplate instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/DeletePollVoteResponse.java b/client/src/main/java/com/fastcomments/model/DeletePollVoteResponse.java index b4ca5511..cfdfdf46 100644 --- a/client/src/main/java/com/fastcomments/model/DeletePollVoteResponse.java +++ b/client/src/main/java/com/fastcomments/model/DeletePollVoteResponse.java @@ -102,6 +102,50 @@ public void setPoll(@javax.annotation.Nonnull CommentPoll poll) { this.poll = poll; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DeletePollVoteResponse instance itself + */ + public DeletePollVoteResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } DeletePollVoteResponse deletePollVoteResponse = (DeletePollVoteResponse) o; return Objects.equals(this.status, deletePollVoteResponse.status) && - Objects.equals(this.poll, deletePollVoteResponse.poll); + Objects.equals(this.poll, deletePollVoteResponse.poll)&& + Objects.equals(this.additionalProperties, deletePollVoteResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, poll); + return Objects.hash(status, poll, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class DeletePollVoteResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" poll: ").append(toIndentedString(poll)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DeletePollVoteResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DeletePollVoteResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DeletePollVoteResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DeletePollVoteResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, DeletePollVoteResponse value) throws IOExcepti public DeletePollVoteResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DeletePollVoteResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/DeletedCommentResultComment.java b/client/src/main/java/com/fastcomments/model/DeletedCommentResultComment.java index f03dde6f..72611680 100644 --- a/client/src/main/java/com/fastcomments/model/DeletedCommentResultComment.java +++ b/client/src/main/java/com/fastcomments/model/DeletedCommentResultComment.java @@ -148,6 +148,50 @@ public void setUserId(@javax.annotation.Nullable String userId) { this.userId = userId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the DeletedCommentResultComment instance itself + */ + public DeletedCommentResultComment putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -162,12 +206,13 @@ public boolean equals(Object o) { return Objects.equals(this.isDeleted, deletedCommentResultComment.isDeleted) && Objects.equals(this.commentHTML, deletedCommentResultComment.commentHTML) && Objects.equals(this.commenterName, deletedCommentResultComment.commenterName) && - Objects.equals(this.userId, deletedCommentResultComment.userId); + Objects.equals(this.userId, deletedCommentResultComment.userId)&& + Objects.equals(this.additionalProperties, deletedCommentResultComment.additionalProperties); } @Override public int hashCode() { - return Objects.hash(isDeleted, commentHTML, commenterName, userId); + return Objects.hash(isDeleted, commentHTML, commenterName, userId, additionalProperties); } @Override @@ -178,6 +223,7 @@ public String toString() { sb.append(" commentHTML: ").append(toIndentedString(commentHTML)).append("\n"); sb.append(" commenterName: ").append(toIndentedString(commenterName)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -215,14 +261,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DeletedCommentResultComment.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DeletedCommentResultComment` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DeletedCommentResultComment.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -256,6 +294,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DeletedCommentResultComment value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -263,7 +323,28 @@ public void write(JsonWriter out, DeletedCommentResultComment value) throws IOEx public DeletedCommentResultComment read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DeletedCommentResultComment instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/EmailTemplateDefinition.java b/client/src/main/java/com/fastcomments/model/EmailTemplateDefinition.java index d9316e21..85341a2f 100644 --- a/client/src/main/java/com/fastcomments/model/EmailTemplateDefinition.java +++ b/client/src/main/java/com/fastcomments/model/EmailTemplateDefinition.java @@ -166,6 +166,50 @@ public void setDefaultEJS(@javax.annotation.Nonnull String defaultEJS) { this.defaultEJS = defaultEJS; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the EmailTemplateDefinition instance itself + */ + public EmailTemplateDefinition putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -180,12 +224,13 @@ public boolean equals(Object o) { return Objects.equals(this.emailTemplateId, emailTemplateDefinition.emailTemplateId) && Objects.equals(this.defaultTestData, emailTemplateDefinition.defaultTestData) && Objects.equals(this.defaultTranslationsByLocale, emailTemplateDefinition.defaultTranslationsByLocale) && - Objects.equals(this.defaultEJS, emailTemplateDefinition.defaultEJS); + Objects.equals(this.defaultEJS, emailTemplateDefinition.defaultEJS)&& + Objects.equals(this.additionalProperties, emailTemplateDefinition.additionalProperties); } @Override public int hashCode() { - return Objects.hash(emailTemplateId, defaultTestData, defaultTranslationsByLocale, defaultEJS); + return Objects.hash(emailTemplateId, defaultTestData, defaultTranslationsByLocale, defaultEJS, additionalProperties); } @Override @@ -196,6 +241,7 @@ public String toString() { sb.append(" defaultTestData: ").append(toIndentedString(defaultTestData)).append("\n"); sb.append(" defaultTranslationsByLocale: ").append(toIndentedString(defaultTranslationsByLocale)).append("\n"); sb.append(" defaultEJS: ").append(toIndentedString(defaultEJS)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -233,14 +279,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!EmailTemplateDefinition.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `EmailTemplateDefinition` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EmailTemplateDefinition.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -271,6 +309,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, EmailTemplateDefinition value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -278,7 +338,28 @@ public void write(JsonWriter out, EmailTemplateDefinition value) throws IOExcept public EmailTemplateDefinition read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EmailTemplateDefinition instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/EmailTemplateRenderErrorResponse.java b/client/src/main/java/com/fastcomments/model/EmailTemplateRenderErrorResponse.java index 516a5bfb..37eda49f 100644 --- a/client/src/main/java/com/fastcomments/model/EmailTemplateRenderErrorResponse.java +++ b/client/src/main/java/com/fastcomments/model/EmailTemplateRenderErrorResponse.java @@ -221,6 +221,50 @@ public void setLastOccurredAt(@javax.annotation.Nonnull OffsetDateTime lastOccur this.lastOccurredAt = lastOccurredAt; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the EmailTemplateRenderErrorResponse instance itself + */ + public EmailTemplateRenderErrorResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -238,12 +282,13 @@ public boolean equals(Object o) { Objects.equals(this.error, emailTemplateRenderErrorResponse.error) && Objects.equals(this.count, emailTemplateRenderErrorResponse.count) && Objects.equals(this.createdAt, emailTemplateRenderErrorResponse.createdAt) && - Objects.equals(this.lastOccurredAt, emailTemplateRenderErrorResponse.lastOccurredAt); + Objects.equals(this.lastOccurredAt, emailTemplateRenderErrorResponse.lastOccurredAt)&& + Objects.equals(this.additionalProperties, emailTemplateRenderErrorResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, customTemplateId, error, count, createdAt, lastOccurredAt); + return Objects.hash(id, tenantId, customTemplateId, error, count, createdAt, lastOccurredAt, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" count: ").append(toIndentedString(count)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); sb.append(" lastOccurredAt: ").append(toIndentedString(lastOccurredAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,14 +340,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!EmailTemplateRenderErrorResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `EmailTemplateRenderErrorResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EmailTemplateRenderErrorResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -338,6 +376,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, EmailTemplateRenderErrorResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -345,7 +405,28 @@ public void write(JsonWriter out, EmailTemplateRenderErrorResponse value) throws public EmailTemplateRenderErrorResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EmailTemplateRenderErrorResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/EventLogEntry.java b/client/src/main/java/com/fastcomments/model/EventLogEntry.java index 005f3555..2f36612b 100644 --- a/client/src/main/java/com/fastcomments/model/EventLogEntry.java +++ b/client/src/main/java/com/fastcomments/model/EventLogEntry.java @@ -221,6 +221,50 @@ public void setDomain(@javax.annotation.Nullable String domain) { this.domain = domain; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the EventLogEntry instance itself + */ + public EventLogEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -238,12 +282,13 @@ public boolean equals(Object o) { Objects.equals(this.urlId, eventLogEntry.urlId) && Objects.equals(this.broadcastId, eventLogEntry.broadcastId) && Objects.equals(this.data, eventLogEntry.data) && - Objects.equals(this.domain, eventLogEntry.domain); + Objects.equals(this.domain, eventLogEntry.domain)&& + Objects.equals(this.additionalProperties, eventLogEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, createdAt, tenantId, urlId, broadcastId, data, domain); + return Objects.hash(id, createdAt, tenantId, urlId, broadcastId, data, domain, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" broadcastId: ").append(toIndentedString(broadcastId)).append("\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); sb.append(" domain: ").append(toIndentedString(domain)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -294,14 +340,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!EventLogEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `EventLogEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EventLogEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -344,6 +382,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, EventLogEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -351,7 +411,28 @@ public void write(JsonWriter out, EventLogEntry value) throws IOException { public EventLogEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EventLogEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/FComment.java b/client/src/main/java/com/fastcomments/model/FComment.java index c2dcbcbd..89a1fb63 100644 --- a/client/src/main/java/com/fastcomments/model/FComment.java +++ b/client/src/main/java/com/fastcomments/model/FComment.java @@ -1952,6 +1952,50 @@ public void setBotId(@javax.annotation.Nullable String botId) { this.botId = botId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FComment instance itself + */ + public FComment putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -2038,12 +2082,13 @@ public boolean equals(Object o) { Objects.equals(this.requiresVerification, fcomment.requiresVerification) && Objects.equals(this.editKey, fcomment.editKey) && Objects.equals(this.tosAcceptedAt, fcomment.tosAcceptedAt) && - Objects.equals(this.botId, fcomment.botId); + Objects.equals(this.botId, fcomment.botId)&& + Objects.equals(this.additionalProperties, fcomment.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, urlId, urlIdRaw, url, pageTitle, userId, anonUserId, commenterEmail, commenterName, commenterLink, comment, commentHTML, parentId, date, localDateString, localDateHours, votes, votesUp, votesDown, expireAt, verified, verifiedDate, verificationId, notificationSentForParent, notificationSentForParentTenant, reviewed, imported, externalId, externalParentId, avatarSrc, isSpam, permNotSpam, aiDeterminedSpam, hasImages, pageNumber, pageNumberOF, pageNumberNF, hasLinks, hasCode, approved, locale, detectedLanguage, translations, isDeleted, isDeletedUser, isBannedUser, isByAdmin, isByModerator, isPinned, isLocked, flagCount, rating, displayLabel, fromProductId, meta, ipHash, mentions, hashTags, badges, domain, veteranBadgeProcessed, moderationGroupIds, didProcessBadges, fromOfflineRestore, autoplayJobId, autoplayDelayMS, feedbackIds, poll, logs, groupIds, viewCount, requiresVerification, editKey, tosAcceptedAt, botId); + return Objects.hash(id, tenantId, urlId, urlIdRaw, url, pageTitle, userId, anonUserId, commenterEmail, commenterName, commenterLink, comment, commentHTML, parentId, date, localDateString, localDateHours, votes, votesUp, votesDown, expireAt, verified, verifiedDate, verificationId, notificationSentForParent, notificationSentForParentTenant, reviewed, imported, externalId, externalParentId, avatarSrc, isSpam, permNotSpam, aiDeterminedSpam, hasImages, pageNumber, pageNumberOF, pageNumberNF, hasLinks, hasCode, approved, locale, detectedLanguage, translations, isDeleted, isDeletedUser, isBannedUser, isByAdmin, isByModerator, isPinned, isLocked, flagCount, rating, displayLabel, fromProductId, meta, ipHash, mentions, hashTags, badges, domain, veteranBadgeProcessed, moderationGroupIds, didProcessBadges, fromOfflineRestore, autoplayJobId, autoplayDelayMS, feedbackIds, poll, logs, groupIds, viewCount, requiresVerification, editKey, tosAcceptedAt, botId, additionalProperties); } @Override @@ -2126,6 +2171,7 @@ public String toString() { sb.append(" editKey: ").append(toIndentedString(editKey)).append("\n"); sb.append(" tosAcceptedAt: ").append(toIndentedString(tosAcceptedAt)).append("\n"); sb.append(" botId: ").append(toIndentedString(botId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -2163,14 +2209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FComment.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FComment` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FComment.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -2351,6 +2389,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FComment value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -2358,7 +2418,28 @@ public void write(JsonWriter out, FComment value) throws IOException { public FComment read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FComment instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/FeedPost.java b/client/src/main/java/com/fastcomments/model/FeedPost.java index 82d79dd5..406622c5 100644 --- a/client/src/main/java/com/fastcomments/model/FeedPost.java +++ b/client/src/main/java/com/fastcomments/model/FeedPost.java @@ -483,6 +483,50 @@ public void setCommentCount(@javax.annotation.Nullable Integer commentCount) { this.commentCount = commentCount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FeedPost instance itself + */ + public FeedPost putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -509,12 +553,13 @@ public boolean equals(Object o) { Objects.equals(this.links, feedPost.links) && Objects.equals(this.createdAt, feedPost.createdAt) && Objects.equals(this.reacts, feedPost.reacts) && - Objects.equals(this.commentCount, feedPost.commentCount); + Objects.equals(this.commentCount, feedPost.commentCount)&& + Objects.equals(this.additionalProperties, feedPost.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, title, fromUserId, fromUserDisplayName, fromUserAvatar, fromIpHash, tags, weight, meta, contentHTML, media, links, createdAt, reacts, commentCount); + return Objects.hash(id, tenantId, title, fromUserId, fromUserDisplayName, fromUserAvatar, fromIpHash, tags, weight, meta, contentHTML, media, links, createdAt, reacts, commentCount, additionalProperties); } @Override @@ -537,6 +582,7 @@ public String toString() { sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); sb.append(" reacts: ").append(toIndentedString(reacts)).append("\n"); sb.append(" commentCount: ").append(toIndentedString(commentCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -574,14 +620,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FeedPost.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FeedPost` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FeedPost.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -662,6 +700,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FeedPost value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -669,7 +729,28 @@ public void write(JsonWriter out, FeedPost value) throws IOException { public FeedPost read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FeedPost instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/FeedPostLink.java b/client/src/main/java/com/fastcomments/model/FeedPostLink.java index 60ca14b0..7ff31fe0 100644 --- a/client/src/main/java/com/fastcomments/model/FeedPostLink.java +++ b/client/src/main/java/com/fastcomments/model/FeedPostLink.java @@ -148,6 +148,50 @@ public void setUrl(@javax.annotation.Nullable String url) { this.url = url; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FeedPostLink instance itself + */ + public FeedPostLink putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -162,12 +206,13 @@ public boolean equals(Object o) { return Objects.equals(this.text, feedPostLink.text) && Objects.equals(this.title, feedPostLink.title) && Objects.equals(this.description, feedPostLink.description) && - Objects.equals(this.url, feedPostLink.url); + Objects.equals(this.url, feedPostLink.url)&& + Objects.equals(this.additionalProperties, feedPostLink.additionalProperties); } @Override public int hashCode() { - return Objects.hash(text, title, description, url); + return Objects.hash(text, title, description, url, additionalProperties); } @Override @@ -178,6 +223,7 @@ public String toString() { sb.append(" title: ").append(toIndentedString(title)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FeedPostLink is not found in the empty JSON string", FeedPostLink.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FeedPostLink.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FeedPostLink` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("text") != null && !jsonObj.get("text").isJsonNull()) && !jsonObj.get("text").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FeedPostLink value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, FeedPostLink value) throws IOException { public FeedPostLink read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FeedPostLink instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/FeedPostMediaItem.java b/client/src/main/java/com/fastcomments/model/FeedPostMediaItem.java index 9527b569..cadc4442 100644 --- a/client/src/main/java/com/fastcomments/model/FeedPostMediaItem.java +++ b/client/src/main/java/com/fastcomments/model/FeedPostMediaItem.java @@ -135,6 +135,50 @@ public void setSizes(@javax.annotation.Nonnull List size this.sizes = sizes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FeedPostMediaItem instance itself + */ + public FeedPostMediaItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -148,12 +192,13 @@ public boolean equals(Object o) { FeedPostMediaItem feedPostMediaItem = (FeedPostMediaItem) o; return Objects.equals(this.title, feedPostMediaItem.title) && Objects.equals(this.linkUrl, feedPostMediaItem.linkUrl) && - Objects.equals(this.sizes, feedPostMediaItem.sizes); + Objects.equals(this.sizes, feedPostMediaItem.sizes)&& + Objects.equals(this.additionalProperties, feedPostMediaItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(title, linkUrl, sizes); + return Objects.hash(title, linkUrl, sizes, additionalProperties); } @Override @@ -163,6 +208,7 @@ public String toString() { sb.append(" title: ").append(toIndentedString(title)).append("\n"); sb.append(" linkUrl: ").append(toIndentedString(linkUrl)).append("\n"); sb.append(" sizes: ").append(toIndentedString(sizes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -200,14 +246,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FeedPostMediaItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FeedPostMediaItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FeedPostMediaItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -248,6 +286,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FeedPostMediaItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -255,7 +315,28 @@ public void write(JsonWriter out, FeedPostMediaItem value) throws IOException { public FeedPostMediaItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FeedPostMediaItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/FeedPostMediaItemAsset.java b/client/src/main/java/com/fastcomments/model/FeedPostMediaItemAsset.java index 0865a4db..8ef463bd 100644 --- a/client/src/main/java/com/fastcomments/model/FeedPostMediaItemAsset.java +++ b/client/src/main/java/com/fastcomments/model/FeedPostMediaItemAsset.java @@ -124,6 +124,50 @@ public void setSrc(@javax.annotation.Nonnull String src) { this.src = src; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FeedPostMediaItemAsset instance itself + */ + public FeedPostMediaItemAsset putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -137,12 +181,13 @@ public boolean equals(Object o) { FeedPostMediaItemAsset feedPostMediaItemAsset = (FeedPostMediaItemAsset) o; return Objects.equals(this.w, feedPostMediaItemAsset.w) && Objects.equals(this.h, feedPostMediaItemAsset.h) && - Objects.equals(this.src, feedPostMediaItemAsset.src); + Objects.equals(this.src, feedPostMediaItemAsset.src)&& + Objects.equals(this.additionalProperties, feedPostMediaItemAsset.additionalProperties); } @Override public int hashCode() { - return Objects.hash(w, h, src); + return Objects.hash(w, h, src, additionalProperties); } @Override @@ -152,6 +197,7 @@ public String toString() { sb.append(" w: ").append(toIndentedString(w)).append("\n"); sb.append(" h: ").append(toIndentedString(h)).append("\n"); sb.append(" src: ").append(toIndentedString(src)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -189,14 +235,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FeedPostMediaItemAsset.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FeedPostMediaItemAsset` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FeedPostMediaItemAsset.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -224,6 +262,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FeedPostMediaItemAsset value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -231,7 +291,28 @@ public void write(JsonWriter out, FeedPostMediaItemAsset value) throws IOExcepti public FeedPostMediaItemAsset read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FeedPostMediaItemAsset instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/FeedPostStats.java b/client/src/main/java/com/fastcomments/model/FeedPostStats.java index a0db647d..15301e40 100644 --- a/client/src/main/java/com/fastcomments/model/FeedPostStats.java +++ b/client/src/main/java/com/fastcomments/model/FeedPostStats.java @@ -110,6 +110,50 @@ public void setCommentCount(@javax.annotation.Nullable Integer commentCount) { this.commentCount = commentCount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FeedPostStats instance itself + */ + public FeedPostStats putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -122,12 +166,13 @@ public boolean equals(Object o) { } FeedPostStats feedPostStats = (FeedPostStats) o; return Objects.equals(this.reacts, feedPostStats.reacts) && - Objects.equals(this.commentCount, feedPostStats.commentCount); + Objects.equals(this.commentCount, feedPostStats.commentCount)&& + Objects.equals(this.additionalProperties, feedPostStats.additionalProperties); } @Override public int hashCode() { - return Objects.hash(reacts, commentCount); + return Objects.hash(reacts, commentCount, additionalProperties); } @Override @@ -136,6 +181,7 @@ public String toString() { sb.append("class FeedPostStats {\n"); sb.append(" reacts: ").append(toIndentedString(reacts)).append("\n"); sb.append(" commentCount: ").append(toIndentedString(commentCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -172,14 +218,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in FeedPostStats is not found in the empty JSON string", FeedPostStats.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FeedPostStats.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FeedPostStats` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -198,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FeedPostStats value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,7 +265,28 @@ public void write(JsonWriter out, FeedPostStats value) throws IOException { public FeedPostStats read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FeedPostStats instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/FeedPostsStatsResponse.java b/client/src/main/java/com/fastcomments/model/FeedPostsStatsResponse.java index 2d1d3698..c0b07281 100644 --- a/client/src/main/java/com/fastcomments/model/FeedPostsStatsResponse.java +++ b/client/src/main/java/com/fastcomments/model/FeedPostsStatsResponse.java @@ -112,6 +112,50 @@ public void setStats(@javax.annotation.Nonnull Map stats) this.stats = stats; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FeedPostsStatsResponse instance itself + */ + public FeedPostsStatsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } FeedPostsStatsResponse feedPostsStatsResponse = (FeedPostsStatsResponse) o; return Objects.equals(this.status, feedPostsStatsResponse.status) && - Objects.equals(this.stats, feedPostsStatsResponse.stats); + Objects.equals(this.stats, feedPostsStatsResponse.stats)&& + Objects.equals(this.additionalProperties, feedPostsStatsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, stats); + return Objects.hash(status, stats, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class FeedPostsStatsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" stats: ").append(toIndentedString(stats)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FeedPostsStatsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FeedPostsStatsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FeedPostsStatsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -209,6 +247,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FeedPostsStatsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -216,7 +276,28 @@ public void write(JsonWriter out, FeedPostsStatsResponse value) throws IOExcepti public FeedPostsStatsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FeedPostsStatsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/FindCommentsByRangeItem.java b/client/src/main/java/com/fastcomments/model/FindCommentsByRangeItem.java index 29674807..07cdf2ce 100644 --- a/client/src/main/java/com/fastcomments/model/FindCommentsByRangeItem.java +++ b/client/src/main/java/com/fastcomments/model/FindCommentsByRangeItem.java @@ -102,6 +102,50 @@ public void setResult(@javax.annotation.Nonnull QuestionResult result) { this.result = result; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FindCommentsByRangeItem instance itself + */ + public FindCommentsByRangeItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } FindCommentsByRangeItem findCommentsByRangeItem = (FindCommentsByRangeItem) o; return Objects.equals(this.comment, findCommentsByRangeItem.comment) && - Objects.equals(this.result, findCommentsByRangeItem.result); + Objects.equals(this.result, findCommentsByRangeItem.result)&& + Objects.equals(this.additionalProperties, findCommentsByRangeItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(comment, result); + return Objects.hash(comment, result, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class FindCommentsByRangeItem {\n"); sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FindCommentsByRangeItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FindCommentsByRangeItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FindCommentsByRangeItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -203,6 +241,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FindCommentsByRangeItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -210,7 +270,28 @@ public void write(JsonWriter out, FindCommentsByRangeItem value) throws IOExcept public FindCommentsByRangeItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FindCommentsByRangeItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/FindCommentsByRangeResponse.java b/client/src/main/java/com/fastcomments/model/FindCommentsByRangeResponse.java index 259b36db..d21c91dc 100644 --- a/client/src/main/java/com/fastcomments/model/FindCommentsByRangeResponse.java +++ b/client/src/main/java/com/fastcomments/model/FindCommentsByRangeResponse.java @@ -112,6 +112,50 @@ public void setCreatedAt(@javax.annotation.Nonnull OffsetDateTime createdAt) { this.createdAt = createdAt; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FindCommentsByRangeResponse instance itself + */ + public FindCommentsByRangeResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } FindCommentsByRangeResponse findCommentsByRangeResponse = (FindCommentsByRangeResponse) o; return Objects.equals(this.results, findCommentsByRangeResponse.results) && - Objects.equals(this.createdAt, findCommentsByRangeResponse.createdAt); + Objects.equals(this.createdAt, findCommentsByRangeResponse.createdAt)&& + Objects.equals(this.additionalProperties, findCommentsByRangeResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(results, createdAt); + return Objects.hash(results, createdAt, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class FindCommentsByRangeResponse {\n"); sb.append(" results: ").append(toIndentedString(results)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FindCommentsByRangeResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FindCommentsByRangeResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FindCommentsByRangeResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -217,6 +255,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FindCommentsByRangeResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -224,7 +284,28 @@ public void write(JsonWriter out, FindCommentsByRangeResponse value) throws IOEx public FindCommentsByRangeResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FindCommentsByRangeResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/FlagCommentResponse.java b/client/src/main/java/com/fastcomments/model/FlagCommentResponse.java index 86e1da13..e03eb0fc 100644 --- a/client/src/main/java/com/fastcomments/model/FlagCommentResponse.java +++ b/client/src/main/java/com/fastcomments/model/FlagCommentResponse.java @@ -173,6 +173,50 @@ public void setWasUnapproved(@javax.annotation.Nullable Boolean wasUnapproved) { this.wasUnapproved = wasUnapproved; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the FlagCommentResponse instance itself + */ + public FlagCommentResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -188,12 +232,13 @@ public boolean equals(Object o) { Objects.equals(this.status, flagCommentResponse.status) && Objects.equals(this.code, flagCommentResponse.code) && Objects.equals(this.reason, flagCommentResponse.reason) && - Objects.equals(this.wasUnapproved, flagCommentResponse.wasUnapproved); + Objects.equals(this.wasUnapproved, flagCommentResponse.wasUnapproved)&& + Objects.equals(this.additionalProperties, flagCommentResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(statusCode, status, code, reason, wasUnapproved); + return Objects.hash(statusCode, status, code, reason, wasUnapproved, additionalProperties); } @Override @@ -205,6 +250,7 @@ public String toString() { sb.append(" code: ").append(toIndentedString(code)).append("\n"); sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); sb.append(" wasUnapproved: ").append(toIndentedString(wasUnapproved)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -242,14 +288,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FlagCommentResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FlagCommentResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FlagCommentResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -282,6 +320,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FlagCommentResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -289,7 +349,28 @@ public void write(JsonWriter out, FlagCommentResponse value) throws IOException public FlagCommentResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + FlagCommentResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetAuditLogsResponse.java b/client/src/main/java/com/fastcomments/model/GetAuditLogsResponse.java index 9a4ed54c..3f75025a 100644 --- a/client/src/main/java/com/fastcomments/model/GetAuditLogsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetAuditLogsResponse.java @@ -112,6 +112,50 @@ public void setAuditLogs(@javax.annotation.Nonnull List auditLogs) this.auditLogs = auditLogs; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetAuditLogsResponse instance itself + */ + public GetAuditLogsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetAuditLogsResponse getAuditLogsResponse = (GetAuditLogsResponse) o; return Objects.equals(this.status, getAuditLogsResponse.status) && - Objects.equals(this.auditLogs, getAuditLogsResponse.auditLogs); + Objects.equals(this.auditLogs, getAuditLogsResponse.auditLogs)&& + Objects.equals(this.additionalProperties, getAuditLogsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, auditLogs); + return Objects.hash(status, auditLogs, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetAuditLogsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" auditLogs: ").append(toIndentedString(auditLogs)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetAuditLogsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetAuditLogsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetAuditLogsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetAuditLogsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetAuditLogsResponse value) throws IOException public GetAuditLogsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetAuditLogsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetCachedNotificationCountResponse.java b/client/src/main/java/com/fastcomments/model/GetCachedNotificationCountResponse.java index 16fb1d60..1d542b4c 100644 --- a/client/src/main/java/com/fastcomments/model/GetCachedNotificationCountResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetCachedNotificationCountResponse.java @@ -102,6 +102,50 @@ public void setData(@javax.annotation.Nonnull UserNotificationCount data) { this.data = data; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetCachedNotificationCountResponse instance itself + */ + public GetCachedNotificationCountResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } GetCachedNotificationCountResponse getCachedNotificationCountResponse = (GetCachedNotificationCountResponse) o; return Objects.equals(this.status, getCachedNotificationCountResponse.status) && - Objects.equals(this.data, getCachedNotificationCountResponse.data); + Objects.equals(this.data, getCachedNotificationCountResponse.data)&& + Objects.equals(this.additionalProperties, getCachedNotificationCountResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, data); + return Objects.hash(status, data, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class GetCachedNotificationCountResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetCachedNotificationCountResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetCachedNotificationCountResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetCachedNotificationCountResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetCachedNotificationCountResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, GetCachedNotificationCountResponse value) thro public GetCachedNotificationCountResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetCachedNotificationCountResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetCommentBanStatusResponse.java b/client/src/main/java/com/fastcomments/model/GetCommentBanStatusResponse.java index c35646c0..58ae02d0 100644 --- a/client/src/main/java/com/fastcomments/model/GetCommentBanStatusResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetCommentBanStatusResponse.java @@ -124,6 +124,50 @@ public void setCanIPBan(@javax.annotation.Nullable Boolean canIPBan) { this.canIPBan = canIPBan; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetCommentBanStatusResponse instance itself + */ + public GetCommentBanStatusResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -137,12 +181,13 @@ public boolean equals(Object o) { GetCommentBanStatusResponse getCommentBanStatusResponse = (GetCommentBanStatusResponse) o; return Objects.equals(this.status, getCommentBanStatusResponse.status) && Objects.equals(this.emailDomain, getCommentBanStatusResponse.emailDomain) && - Objects.equals(this.canIPBan, getCommentBanStatusResponse.canIPBan); + Objects.equals(this.canIPBan, getCommentBanStatusResponse.canIPBan)&& + Objects.equals(this.additionalProperties, getCommentBanStatusResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, emailDomain, canIPBan); + return Objects.hash(status, emailDomain, canIPBan, additionalProperties); } @Override @@ -152,6 +197,7 @@ public String toString() { sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" emailDomain: ").append(toIndentedString(emailDomain)).append("\n"); sb.append(" canIPBan: ").append(toIndentedString(canIPBan)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -189,14 +235,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetCommentBanStatusResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetCommentBanStatusResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetCommentBanStatusResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -227,6 +265,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetCommentBanStatusResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -234,7 +294,28 @@ public void write(JsonWriter out, GetCommentBanStatusResponse value) throws IOEx public GetCommentBanStatusResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetCommentBanStatusResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetCommentVoteUserNamesSuccessResponse.java b/client/src/main/java/com/fastcomments/model/GetCommentVoteUserNamesSuccessResponse.java index cecf0089..93b2576e 100644 --- a/client/src/main/java/com/fastcomments/model/GetCommentVoteUserNamesSuccessResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetCommentVoteUserNamesSuccessResponse.java @@ -135,6 +135,50 @@ public void setHasMore(@javax.annotation.Nonnull Boolean hasMore) { this.hasMore = hasMore; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetCommentVoteUserNamesSuccessResponse instance itself + */ + public GetCommentVoteUserNamesSuccessResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -148,12 +192,13 @@ public boolean equals(Object o) { GetCommentVoteUserNamesSuccessResponse getCommentVoteUserNamesSuccessResponse = (GetCommentVoteUserNamesSuccessResponse) o; return Objects.equals(this.status, getCommentVoteUserNamesSuccessResponse.status) && Objects.equals(this.voteUserNames, getCommentVoteUserNamesSuccessResponse.voteUserNames) && - Objects.equals(this.hasMore, getCommentVoteUserNamesSuccessResponse.hasMore); + Objects.equals(this.hasMore, getCommentVoteUserNamesSuccessResponse.hasMore)&& + Objects.equals(this.additionalProperties, getCommentVoteUserNamesSuccessResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, voteUserNames, hasMore); + return Objects.hash(status, voteUserNames, hasMore, additionalProperties); } @Override @@ -163,6 +208,7 @@ public String toString() { sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" voteUserNames: ").append(toIndentedString(voteUserNames)).append("\n"); sb.append(" hasMore: ").append(toIndentedString(hasMore)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -200,14 +246,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetCommentVoteUserNamesSuccessResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetCommentVoteUserNamesSuccessResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetCommentVoteUserNamesSuccessResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -240,6 +278,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetCommentVoteUserNamesSuccessResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -247,7 +307,28 @@ public void write(JsonWriter out, GetCommentVoteUserNamesSuccessResponse value) public GetCommentVoteUserNamesSuccessResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetCommentVoteUserNamesSuccessResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetCommentsResponsePublicComment.java b/client/src/main/java/com/fastcomments/model/GetCommentsResponsePublicComment.java index b6a512f2..4e24fb98 100644 --- a/client/src/main/java/com/fastcomments/model/GetCommentsResponsePublicComment.java +++ b/client/src/main/java/com/fastcomments/model/GetCommentsResponsePublicComment.java @@ -651,6 +651,50 @@ public void setCustomConfig(@javax.annotation.Nullable CustomConfigParameters cu this.customConfig = customConfig; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetCommentsResponsePublicComment instance itself + */ + public GetCommentsResponsePublicComment putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -685,12 +729,13 @@ public boolean equals(Object o) { Objects.equals(this.hasMore, getCommentsResponsePublicComment.hasMore) && Objects.equals(this.isClosed, getCommentsResponsePublicComment.isClosed) && Objects.equals(this.presencePollState, getCommentsResponsePublicComment.presencePollState) && - Objects.equals(this.customConfig, getCommentsResponsePublicComment.customConfig); + Objects.equals(this.customConfig, getCommentsResponsePublicComment.customConfig)&& + Objects.equals(this.additionalProperties, getCommentsResponsePublicComment.additionalProperties); } @Override public int hashCode() { - return Objects.hash(statusCode, status, code, reason, translatedWarning, comments, user, urlIdClean, lastGenDate, includesPastPages, isDemo, commentCount, isSiteAdmin, hasBillingIssue, moduleData, pageNumber, isWhiteLabeled, isProd, isCrawler, notificationCount, hasMore, isClosed, presencePollState, customConfig); + return Objects.hash(statusCode, status, code, reason, translatedWarning, comments, user, urlIdClean, lastGenDate, includesPastPages, isDemo, commentCount, isSiteAdmin, hasBillingIssue, moduleData, pageNumber, isWhiteLabeled, isProd, isCrawler, notificationCount, hasMore, isClosed, presencePollState, customConfig, additionalProperties); } @Override @@ -721,6 +766,7 @@ public String toString() { sb.append(" isClosed: ").append(toIndentedString(isClosed)).append("\n"); sb.append(" presencePollState: ").append(toIndentedString(presencePollState)).append("\n"); sb.append(" customConfig: ").append(toIndentedString(customConfig)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -758,14 +804,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetCommentsResponsePublicComment.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetCommentsResponsePublicComment` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetCommentsResponsePublicComment.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -823,6 +861,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetCommentsResponsePublicComment value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -830,7 +890,28 @@ public void write(JsonWriter out, GetCommentsResponsePublicComment value) throws public GetCommentsResponsePublicComment read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetCommentsResponsePublicComment instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetEmailTemplateDefinitionsResponse.java b/client/src/main/java/com/fastcomments/model/GetEmailTemplateDefinitionsResponse.java index 0470e457..935446d3 100644 --- a/client/src/main/java/com/fastcomments/model/GetEmailTemplateDefinitionsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetEmailTemplateDefinitionsResponse.java @@ -112,6 +112,50 @@ public void setDefinitions(@javax.annotation.Nonnull List additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetEmailTemplateDefinitionsResponse instance itself + */ + public GetEmailTemplateDefinitionsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetEmailTemplateDefinitionsResponse getEmailTemplateDefinitionsResponse = (GetEmailTemplateDefinitionsResponse) o; return Objects.equals(this.status, getEmailTemplateDefinitionsResponse.status) && - Objects.equals(this.definitions, getEmailTemplateDefinitionsResponse.definitions); + Objects.equals(this.definitions, getEmailTemplateDefinitionsResponse.definitions)&& + Objects.equals(this.additionalProperties, getEmailTemplateDefinitionsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, definitions); + return Objects.hash(status, definitions, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetEmailTemplateDefinitionsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" definitions: ").append(toIndentedString(definitions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetEmailTemplateDefinitionsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetEmailTemplateDefinitionsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetEmailTemplateDefinitionsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetEmailTemplateDefinitionsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetEmailTemplateDefinitionsResponse value) thr public GetEmailTemplateDefinitionsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetEmailTemplateDefinitionsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetEmailTemplateRenderErrorsResponse.java b/client/src/main/java/com/fastcomments/model/GetEmailTemplateRenderErrorsResponse.java index ed6b0e1c..ce016af3 100644 --- a/client/src/main/java/com/fastcomments/model/GetEmailTemplateRenderErrorsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetEmailTemplateRenderErrorsResponse.java @@ -112,6 +112,50 @@ public void setRenderErrors(@javax.annotation.Nonnull List additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetEmailTemplateRenderErrorsResponse instance itself + */ + public GetEmailTemplateRenderErrorsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetEmailTemplateRenderErrorsResponse getEmailTemplateRenderErrorsResponse = (GetEmailTemplateRenderErrorsResponse) o; return Objects.equals(this.status, getEmailTemplateRenderErrorsResponse.status) && - Objects.equals(this.renderErrors, getEmailTemplateRenderErrorsResponse.renderErrors); + Objects.equals(this.renderErrors, getEmailTemplateRenderErrorsResponse.renderErrors)&& + Objects.equals(this.additionalProperties, getEmailTemplateRenderErrorsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, renderErrors); + return Objects.hash(status, renderErrors, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetEmailTemplateRenderErrorsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" renderErrors: ").append(toIndentedString(renderErrors)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetEmailTemplateRenderErrorsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetEmailTemplateRenderErrorsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetEmailTemplateRenderErrorsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetEmailTemplateRenderErrorsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetEmailTemplateRenderErrorsResponse value) th public GetEmailTemplateRenderErrorsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetEmailTemplateRenderErrorsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetEmailTemplateResponse.java b/client/src/main/java/com/fastcomments/model/GetEmailTemplateResponse.java index 26143999..c9e8df59 100644 --- a/client/src/main/java/com/fastcomments/model/GetEmailTemplateResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetEmailTemplateResponse.java @@ -102,6 +102,50 @@ public void setEmailTemplate(@javax.annotation.Nonnull CustomEmailTemplate email this.emailTemplate = emailTemplate; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetEmailTemplateResponse instance itself + */ + public GetEmailTemplateResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } GetEmailTemplateResponse getEmailTemplateResponse = (GetEmailTemplateResponse) o; return Objects.equals(this.status, getEmailTemplateResponse.status) && - Objects.equals(this.emailTemplate, getEmailTemplateResponse.emailTemplate); + Objects.equals(this.emailTemplate, getEmailTemplateResponse.emailTemplate)&& + Objects.equals(this.additionalProperties, getEmailTemplateResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, emailTemplate); + return Objects.hash(status, emailTemplate, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class GetEmailTemplateResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" emailTemplate: ").append(toIndentedString(emailTemplate)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetEmailTemplateResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetEmailTemplateResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetEmailTemplateResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetEmailTemplateResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, GetEmailTemplateResponse value) throws IOExcep public GetEmailTemplateResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetEmailTemplateResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetEmailTemplatesResponse.java b/client/src/main/java/com/fastcomments/model/GetEmailTemplatesResponse.java index a5315b83..724193cd 100644 --- a/client/src/main/java/com/fastcomments/model/GetEmailTemplatesResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetEmailTemplatesResponse.java @@ -112,6 +112,50 @@ public void setEmailTemplates(@javax.annotation.Nonnull List additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetEmailTemplatesResponse instance itself + */ + public GetEmailTemplatesResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetEmailTemplatesResponse getEmailTemplatesResponse = (GetEmailTemplatesResponse) o; return Objects.equals(this.status, getEmailTemplatesResponse.status) && - Objects.equals(this.emailTemplates, getEmailTemplatesResponse.emailTemplates); + Objects.equals(this.emailTemplates, getEmailTemplatesResponse.emailTemplates)&& + Objects.equals(this.additionalProperties, getEmailTemplatesResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, emailTemplates); + return Objects.hash(status, emailTemplates, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetEmailTemplatesResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" emailTemplates: ").append(toIndentedString(emailTemplates)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetEmailTemplatesResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetEmailTemplatesResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetEmailTemplatesResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetEmailTemplatesResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetEmailTemplatesResponse value) throws IOExce public GetEmailTemplatesResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetEmailTemplatesResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetFeedPostsResponse.java b/client/src/main/java/com/fastcomments/model/GetFeedPostsResponse.java index bbcf6a66..40affd46 100644 --- a/client/src/main/java/com/fastcomments/model/GetFeedPostsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetFeedPostsResponse.java @@ -112,6 +112,50 @@ public void setFeedPosts(@javax.annotation.Nonnull List feedPosts) { this.feedPosts = feedPosts; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetFeedPostsResponse instance itself + */ + public GetFeedPostsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetFeedPostsResponse getFeedPostsResponse = (GetFeedPostsResponse) o; return Objects.equals(this.status, getFeedPostsResponse.status) && - Objects.equals(this.feedPosts, getFeedPostsResponse.feedPosts); + Objects.equals(this.feedPosts, getFeedPostsResponse.feedPosts)&& + Objects.equals(this.additionalProperties, getFeedPostsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, feedPosts); + return Objects.hash(status, feedPosts, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetFeedPostsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" feedPosts: ").append(toIndentedString(feedPosts)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetFeedPostsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetFeedPostsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetFeedPostsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetFeedPostsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetFeedPostsResponse value) throws IOException public GetFeedPostsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetFeedPostsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetHashTagsResponse.java b/client/src/main/java/com/fastcomments/model/GetHashTagsResponse.java index b660b037..59f0d95e 100644 --- a/client/src/main/java/com/fastcomments/model/GetHashTagsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetHashTagsResponse.java @@ -112,6 +112,50 @@ public void setHashTags(@javax.annotation.Nonnull List hashTags) this.hashTags = hashTags; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetHashTagsResponse instance itself + */ + public GetHashTagsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetHashTagsResponse getHashTagsResponse = (GetHashTagsResponse) o; return Objects.equals(this.status, getHashTagsResponse.status) && - Objects.equals(this.hashTags, getHashTagsResponse.hashTags); + Objects.equals(this.hashTags, getHashTagsResponse.hashTags)&& + Objects.equals(this.additionalProperties, getHashTagsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, hashTags); + return Objects.hash(status, hashTags, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetHashTagsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" hashTags: ").append(toIndentedString(hashTags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetHashTagsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetHashTagsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetHashTagsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetHashTagsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetHashTagsResponse value) throws IOException public GetHashTagsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetHashTagsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetMeResponse.java b/client/src/main/java/com/fastcomments/model/GetMeResponse.java index 44a990cd..191f33fb 100644 --- a/client/src/main/java/com/fastcomments/model/GetMeResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetMeResponse.java @@ -257,6 +257,50 @@ public void setEmail(@javax.annotation.Nullable String email) { this.email = email; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetMeResponse instance itself + */ + public GetMeResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -275,12 +319,13 @@ public boolean equals(Object o) { Objects.equals(this.scopes, getMeResponse.scopes) && Objects.equals(this.userId, getMeResponse.userId) && Objects.equals(this.username, getMeResponse.username) && - Objects.equals(this.email, getMeResponse.email); + Objects.equals(this.email, getMeResponse.email)&& + Objects.equals(this.additionalProperties, getMeResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, tenantId, tenantName, authType, scopes, userId, username, email); + return Objects.hash(status, tenantId, tenantName, authType, scopes, userId, username, email, additionalProperties); } @Override @@ -295,6 +340,7 @@ public String toString() { sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); sb.append(" username: ").append(toIndentedString(username)).append("\n"); sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -332,14 +378,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetMeResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetMeResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetMeResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -389,6 +427,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetMeResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -396,7 +456,28 @@ public void write(JsonWriter out, GetMeResponse value) throws IOException { public GetMeResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetMeResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetModeratorResponse.java b/client/src/main/java/com/fastcomments/model/GetModeratorResponse.java index cb1efc95..f0fcd7f7 100644 --- a/client/src/main/java/com/fastcomments/model/GetModeratorResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetModeratorResponse.java @@ -102,6 +102,50 @@ public void setModerator(@javax.annotation.Nonnull Moderator moderator) { this.moderator = moderator; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetModeratorResponse instance itself + */ + public GetModeratorResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } GetModeratorResponse getModeratorResponse = (GetModeratorResponse) o; return Objects.equals(this.status, getModeratorResponse.status) && - Objects.equals(this.moderator, getModeratorResponse.moderator); + Objects.equals(this.moderator, getModeratorResponse.moderator)&& + Objects.equals(this.additionalProperties, getModeratorResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, moderator); + return Objects.hash(status, moderator, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class GetModeratorResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" moderator: ").append(toIndentedString(moderator)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetModeratorResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetModeratorResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetModeratorResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetModeratorResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, GetModeratorResponse value) throws IOException public GetModeratorResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetModeratorResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetModeratorsResponse.java b/client/src/main/java/com/fastcomments/model/GetModeratorsResponse.java index 9ac90ca5..286223d5 100644 --- a/client/src/main/java/com/fastcomments/model/GetModeratorsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetModeratorsResponse.java @@ -112,6 +112,50 @@ public void setModerators(@javax.annotation.Nonnull List moderators) this.moderators = moderators; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetModeratorsResponse instance itself + */ + public GetModeratorsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetModeratorsResponse getModeratorsResponse = (GetModeratorsResponse) o; return Objects.equals(this.status, getModeratorsResponse.status) && - Objects.equals(this.moderators, getModeratorsResponse.moderators); + Objects.equals(this.moderators, getModeratorsResponse.moderators)&& + Objects.equals(this.additionalProperties, getModeratorsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, moderators); + return Objects.hash(status, moderators, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetModeratorsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" moderators: ").append(toIndentedString(moderators)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetModeratorsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetModeratorsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetModeratorsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetModeratorsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetModeratorsResponse value) throws IOExceptio public GetModeratorsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetModeratorsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetNotificationCountResponse.java b/client/src/main/java/com/fastcomments/model/GetNotificationCountResponse.java index 5f9d6446..3e66e282 100644 --- a/client/src/main/java/com/fastcomments/model/GetNotificationCountResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetNotificationCountResponse.java @@ -101,6 +101,50 @@ public void setCount(@javax.annotation.Nonnull Double count) { this.count = count; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetNotificationCountResponse instance itself + */ + public GetNotificationCountResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -113,12 +157,13 @@ public boolean equals(Object o) { } GetNotificationCountResponse getNotificationCountResponse = (GetNotificationCountResponse) o; return Objects.equals(this.status, getNotificationCountResponse.status) && - Objects.equals(this.count, getNotificationCountResponse.count); + Objects.equals(this.count, getNotificationCountResponse.count)&& + Objects.equals(this.additionalProperties, getNotificationCountResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, count); + return Objects.hash(status, count, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class GetNotificationCountResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -164,14 +210,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetNotificationCountResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetNotificationCountResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetNotificationCountResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -198,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetNotificationCountResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,7 +265,28 @@ public void write(JsonWriter out, GetNotificationCountResponse value) throws IOE public GetNotificationCountResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetNotificationCountResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetNotificationsResponse.java b/client/src/main/java/com/fastcomments/model/GetNotificationsResponse.java index 16137c47..21c79b72 100644 --- a/client/src/main/java/com/fastcomments/model/GetNotificationsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetNotificationsResponse.java @@ -112,6 +112,50 @@ public void setNotifications(@javax.annotation.Nonnull List no this.notifications = notifications; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetNotificationsResponse instance itself + */ + public GetNotificationsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetNotificationsResponse getNotificationsResponse = (GetNotificationsResponse) o; return Objects.equals(this.status, getNotificationsResponse.status) && - Objects.equals(this.notifications, getNotificationsResponse.notifications); + Objects.equals(this.notifications, getNotificationsResponse.notifications)&& + Objects.equals(this.additionalProperties, getNotificationsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, notifications); + return Objects.hash(status, notifications, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetNotificationsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" notifications: ").append(toIndentedString(notifications)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetNotificationsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetNotificationsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetNotificationsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetNotificationsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetNotificationsResponse value) throws IOExcep public GetNotificationsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetNotificationsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetPendingWebhookEventCountResponse.java b/client/src/main/java/com/fastcomments/model/GetPendingWebhookEventCountResponse.java index 78f3daa2..338f61f4 100644 --- a/client/src/main/java/com/fastcomments/model/GetPendingWebhookEventCountResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetPendingWebhookEventCountResponse.java @@ -101,6 +101,50 @@ public void setCount(@javax.annotation.Nonnull Double count) { this.count = count; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetPendingWebhookEventCountResponse instance itself + */ + public GetPendingWebhookEventCountResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -113,12 +157,13 @@ public boolean equals(Object o) { } GetPendingWebhookEventCountResponse getPendingWebhookEventCountResponse = (GetPendingWebhookEventCountResponse) o; return Objects.equals(this.status, getPendingWebhookEventCountResponse.status) && - Objects.equals(this.count, getPendingWebhookEventCountResponse.count); + Objects.equals(this.count, getPendingWebhookEventCountResponse.count)&& + Objects.equals(this.additionalProperties, getPendingWebhookEventCountResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, count); + return Objects.hash(status, count, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class GetPendingWebhookEventCountResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -164,14 +210,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetPendingWebhookEventCountResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetPendingWebhookEventCountResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetPendingWebhookEventCountResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -198,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetPendingWebhookEventCountResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,7 +265,28 @@ public void write(JsonWriter out, GetPendingWebhookEventCountResponse value) thr public GetPendingWebhookEventCountResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetPendingWebhookEventCountResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetPendingWebhookEventsResponse.java b/client/src/main/java/com/fastcomments/model/GetPendingWebhookEventsResponse.java index 99e0e6b6..c5115518 100644 --- a/client/src/main/java/com/fastcomments/model/GetPendingWebhookEventsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetPendingWebhookEventsResponse.java @@ -112,6 +112,50 @@ public void setPendingWebhookEvents(@javax.annotation.Nonnull List additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetPendingWebhookEventsResponse instance itself + */ + public GetPendingWebhookEventsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetPendingWebhookEventsResponse getPendingWebhookEventsResponse = (GetPendingWebhookEventsResponse) o; return Objects.equals(this.status, getPendingWebhookEventsResponse.status) && - Objects.equals(this.pendingWebhookEvents, getPendingWebhookEventsResponse.pendingWebhookEvents); + Objects.equals(this.pendingWebhookEvents, getPendingWebhookEventsResponse.pendingWebhookEvents)&& + Objects.equals(this.additionalProperties, getPendingWebhookEventsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, pendingWebhookEvents); + return Objects.hash(status, pendingWebhookEvents, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetPendingWebhookEventsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" pendingWebhookEvents: ").append(toIndentedString(pendingWebhookEvents)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetPendingWebhookEventsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetPendingWebhookEventsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetPendingWebhookEventsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetPendingWebhookEventsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetPendingWebhookEventsResponse value) throws public GetPendingWebhookEventsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetPendingWebhookEventsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetPollResponse.java b/client/src/main/java/com/fastcomments/model/GetPollResponse.java index 930fbfd9..27321b67 100644 --- a/client/src/main/java/com/fastcomments/model/GetPollResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetPollResponse.java @@ -102,6 +102,50 @@ public void setPoll(@javax.annotation.Nonnull CommentPoll poll) { this.poll = poll; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetPollResponse instance itself + */ + public GetPollResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } GetPollResponse getPollResponse = (GetPollResponse) o; return Objects.equals(this.status, getPollResponse.status) && - Objects.equals(this.poll, getPollResponse.poll); + Objects.equals(this.poll, getPollResponse.poll)&& + Objects.equals(this.additionalProperties, getPollResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, poll); + return Objects.hash(status, poll, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class GetPollResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" poll: ").append(toIndentedString(poll)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetPollResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetPollResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetPollResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetPollResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, GetPollResponse value) throws IOException { public GetPollResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetPollResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetPollVoteResponse.java b/client/src/main/java/com/fastcomments/model/GetPollVoteResponse.java index 0eae4c64..62234d43 100644 --- a/client/src/main/java/com/fastcomments/model/GetPollVoteResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetPollVoteResponse.java @@ -102,6 +102,50 @@ public void setPollVote(@javax.annotation.Nonnull PublicPollVote pollVote) { this.pollVote = pollVote; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetPollVoteResponse instance itself + */ + public GetPollVoteResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } GetPollVoteResponse getPollVoteResponse = (GetPollVoteResponse) o; return Objects.equals(this.status, getPollVoteResponse.status) && - Objects.equals(this.pollVote, getPollVoteResponse.pollVote); + Objects.equals(this.pollVote, getPollVoteResponse.pollVote)&& + Objects.equals(this.additionalProperties, getPollVoteResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, pollVote); + return Objects.hash(status, pollVote, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class GetPollVoteResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" pollVote: ").append(toIndentedString(pollVote)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetPollVoteResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetPollVoteResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetPollVoteResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetPollVoteResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, GetPollVoteResponse value) throws IOException public GetPollVoteResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetPollVoteResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetPollVoterNamesSuccessResponse.java b/client/src/main/java/com/fastcomments/model/GetPollVoterNamesSuccessResponse.java index d4bedccd..90b809d8 100644 --- a/client/src/main/java/com/fastcomments/model/GetPollVoterNamesSuccessResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetPollVoterNamesSuccessResponse.java @@ -208,6 +208,50 @@ public void setHasMore(@javax.annotation.Nonnull Boolean hasMore) { this.hasMore = hasMore; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetPollVoterNamesSuccessResponse instance itself + */ + public GetPollVoterNamesSuccessResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -224,12 +268,13 @@ public boolean equals(Object o) { Objects.equals(this.page, getPollVoterNamesSuccessResponse.page) && Objects.equals(this.pageSize, getPollVoterNamesSuccessResponse.pageSize) && Objects.equals(this.total, getPollVoterNamesSuccessResponse.total) && - Objects.equals(this.hasMore, getPollVoterNamesSuccessResponse.hasMore); + Objects.equals(this.hasMore, getPollVoterNamesSuccessResponse.hasMore)&& + Objects.equals(this.additionalProperties, getPollVoterNamesSuccessResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, voters, page, pageSize, total, hasMore); + return Objects.hash(status, voters, page, pageSize, total, hasMore, additionalProperties); } @Override @@ -242,6 +287,7 @@ public String toString() { sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); sb.append(" total: ").append(toIndentedString(total)).append("\n"); sb.append(" hasMore: ").append(toIndentedString(hasMore)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -279,14 +325,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetPollVoterNamesSuccessResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetPollVoterNamesSuccessResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetPollVoterNamesSuccessResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -323,6 +361,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetPollVoterNamesSuccessResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -330,7 +390,28 @@ public void write(JsonWriter out, GetPollVoterNamesSuccessResponse value) throws public GetPollVoterNamesSuccessResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetPollVoterNamesSuccessResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetPollVotesResponse.java b/client/src/main/java/com/fastcomments/model/GetPollVotesResponse.java index ed686bc9..be325254 100644 --- a/client/src/main/java/com/fastcomments/model/GetPollVotesResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetPollVotesResponse.java @@ -112,6 +112,50 @@ public void setPollVotes(@javax.annotation.Nonnull List pollVote this.pollVotes = pollVotes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetPollVotesResponse instance itself + */ + public GetPollVotesResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetPollVotesResponse getPollVotesResponse = (GetPollVotesResponse) o; return Objects.equals(this.status, getPollVotesResponse.status) && - Objects.equals(this.pollVotes, getPollVotesResponse.pollVotes); + Objects.equals(this.pollVotes, getPollVotesResponse.pollVotes)&& + Objects.equals(this.additionalProperties, getPollVotesResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, pollVotes); + return Objects.hash(status, pollVotes, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetPollVotesResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" pollVotes: ").append(toIndentedString(pollVotes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetPollVotesResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetPollVotesResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetPollVotesResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetPollVotesResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetPollVotesResponse value) throws IOException public GetPollVotesResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetPollVotesResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetPublicFeedPostsResponse.java b/client/src/main/java/com/fastcomments/model/GetPublicFeedPostsResponse.java index 9bacf0f8..03e55998 100644 --- a/client/src/main/java/com/fastcomments/model/GetPublicFeedPostsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetPublicFeedPostsResponse.java @@ -137,6 +137,50 @@ public void setUser(@javax.annotation.Nullable UserSessionInfo user) { this.user = user; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetPublicFeedPostsResponse instance itself + */ + public GetPublicFeedPostsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -150,12 +194,13 @@ public boolean equals(Object o) { GetPublicFeedPostsResponse getPublicFeedPostsResponse = (GetPublicFeedPostsResponse) o; return Objects.equals(this.status, getPublicFeedPostsResponse.status) && Objects.equals(this.feedPosts, getPublicFeedPostsResponse.feedPosts) && - Objects.equals(this.user, getPublicFeedPostsResponse.user); + Objects.equals(this.user, getPublicFeedPostsResponse.user)&& + Objects.equals(this.additionalProperties, getPublicFeedPostsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, feedPosts, user); + return Objects.hash(status, feedPosts, user, additionalProperties); } @Override @@ -165,6 +210,7 @@ public String toString() { sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" feedPosts: ").append(toIndentedString(feedPosts)).append("\n"); sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -202,14 +248,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetPublicFeedPostsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetPublicFeedPostsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetPublicFeedPostsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -250,6 +288,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetPublicFeedPostsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -257,7 +317,28 @@ public void write(JsonWriter out, GetPublicFeedPostsResponse value) throws IOExc public GetPublicFeedPostsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetPublicFeedPostsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetQuestionConfigResponse.java b/client/src/main/java/com/fastcomments/model/GetQuestionConfigResponse.java index 87ec3efa..adbc96e5 100644 --- a/client/src/main/java/com/fastcomments/model/GetQuestionConfigResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetQuestionConfigResponse.java @@ -102,6 +102,50 @@ public void setQuestionConfig(@javax.annotation.Nonnull QuestionConfig questionC this.questionConfig = questionConfig; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetQuestionConfigResponse instance itself + */ + public GetQuestionConfigResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } GetQuestionConfigResponse getQuestionConfigResponse = (GetQuestionConfigResponse) o; return Objects.equals(this.status, getQuestionConfigResponse.status) && - Objects.equals(this.questionConfig, getQuestionConfigResponse.questionConfig); + Objects.equals(this.questionConfig, getQuestionConfigResponse.questionConfig)&& + Objects.equals(this.additionalProperties, getQuestionConfigResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, questionConfig); + return Objects.hash(status, questionConfig, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class GetQuestionConfigResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" questionConfig: ").append(toIndentedString(questionConfig)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetQuestionConfigResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetQuestionConfigResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetQuestionConfigResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetQuestionConfigResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, GetQuestionConfigResponse value) throws IOExce public GetQuestionConfigResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetQuestionConfigResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetQuestionConfigsResponse.java b/client/src/main/java/com/fastcomments/model/GetQuestionConfigsResponse.java index a7a76729..318ea45e 100644 --- a/client/src/main/java/com/fastcomments/model/GetQuestionConfigsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetQuestionConfigsResponse.java @@ -112,6 +112,50 @@ public void setQuestionConfigs(@javax.annotation.Nonnull List qu this.questionConfigs = questionConfigs; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetQuestionConfigsResponse instance itself + */ + public GetQuestionConfigsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetQuestionConfigsResponse getQuestionConfigsResponse = (GetQuestionConfigsResponse) o; return Objects.equals(this.status, getQuestionConfigsResponse.status) && - Objects.equals(this.questionConfigs, getQuestionConfigsResponse.questionConfigs); + Objects.equals(this.questionConfigs, getQuestionConfigsResponse.questionConfigs)&& + Objects.equals(this.additionalProperties, getQuestionConfigsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, questionConfigs); + return Objects.hash(status, questionConfigs, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetQuestionConfigsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" questionConfigs: ").append(toIndentedString(questionConfigs)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetQuestionConfigsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetQuestionConfigsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetQuestionConfigsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetQuestionConfigsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetQuestionConfigsResponse value) throws IOExc public GetQuestionConfigsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetQuestionConfigsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetQuestionResultResponse.java b/client/src/main/java/com/fastcomments/model/GetQuestionResultResponse.java index 0e7500c9..fb687dc9 100644 --- a/client/src/main/java/com/fastcomments/model/GetQuestionResultResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetQuestionResultResponse.java @@ -102,6 +102,50 @@ public void setQuestionResult(@javax.annotation.Nonnull QuestionResult questionR this.questionResult = questionResult; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetQuestionResultResponse instance itself + */ + public GetQuestionResultResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } GetQuestionResultResponse getQuestionResultResponse = (GetQuestionResultResponse) o; return Objects.equals(this.status, getQuestionResultResponse.status) && - Objects.equals(this.questionResult, getQuestionResultResponse.questionResult); + Objects.equals(this.questionResult, getQuestionResultResponse.questionResult)&& + Objects.equals(this.additionalProperties, getQuestionResultResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, questionResult); + return Objects.hash(status, questionResult, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class GetQuestionResultResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" questionResult: ").append(toIndentedString(questionResult)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetQuestionResultResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetQuestionResultResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetQuestionResultResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetQuestionResultResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, GetQuestionResultResponse value) throws IOExce public GetQuestionResultResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetQuestionResultResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetQuestionResultsResponse.java b/client/src/main/java/com/fastcomments/model/GetQuestionResultsResponse.java index ab29a6eb..0c920fcd 100644 --- a/client/src/main/java/com/fastcomments/model/GetQuestionResultsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetQuestionResultsResponse.java @@ -112,6 +112,50 @@ public void setQuestionResults(@javax.annotation.Nonnull List qu this.questionResults = questionResults; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetQuestionResultsResponse instance itself + */ + public GetQuestionResultsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetQuestionResultsResponse getQuestionResultsResponse = (GetQuestionResultsResponse) o; return Objects.equals(this.status, getQuestionResultsResponse.status) && - Objects.equals(this.questionResults, getQuestionResultsResponse.questionResults); + Objects.equals(this.questionResults, getQuestionResultsResponse.questionResults)&& + Objects.equals(this.additionalProperties, getQuestionResultsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, questionResults); + return Objects.hash(status, questionResults, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetQuestionResultsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" questionResults: ").append(toIndentedString(questionResults)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetQuestionResultsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetQuestionResultsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetQuestionResultsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetQuestionResultsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetQuestionResultsResponse value) throws IOExc public GetQuestionResultsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetQuestionResultsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetTenantDailyUsagesResponse.java b/client/src/main/java/com/fastcomments/model/GetTenantDailyUsagesResponse.java index 9dfd49dd..284dc768 100644 --- a/client/src/main/java/com/fastcomments/model/GetTenantDailyUsagesResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetTenantDailyUsagesResponse.java @@ -112,6 +112,50 @@ public void setTenantDailyUsages(@javax.annotation.Nonnull List additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetTenantDailyUsagesResponse instance itself + */ + public GetTenantDailyUsagesResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetTenantDailyUsagesResponse getTenantDailyUsagesResponse = (GetTenantDailyUsagesResponse) o; return Objects.equals(this.status, getTenantDailyUsagesResponse.status) && - Objects.equals(this.tenantDailyUsages, getTenantDailyUsagesResponse.tenantDailyUsages); + Objects.equals(this.tenantDailyUsages, getTenantDailyUsagesResponse.tenantDailyUsages)&& + Objects.equals(this.additionalProperties, getTenantDailyUsagesResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, tenantDailyUsages); + return Objects.hash(status, tenantDailyUsages, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetTenantDailyUsagesResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" tenantDailyUsages: ").append(toIndentedString(tenantDailyUsages)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetTenantDailyUsagesResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetTenantDailyUsagesResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetTenantDailyUsagesResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetTenantDailyUsagesResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetTenantDailyUsagesResponse value) throws IOE public GetTenantDailyUsagesResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetTenantDailyUsagesResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetTenantPackageResponse.java b/client/src/main/java/com/fastcomments/model/GetTenantPackageResponse.java index 32e676d9..111fd07e 100644 --- a/client/src/main/java/com/fastcomments/model/GetTenantPackageResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetTenantPackageResponse.java @@ -102,6 +102,50 @@ public void setTenantPackage(@javax.annotation.Nonnull TenantPackage tenantPacka this.tenantPackage = tenantPackage; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetTenantPackageResponse instance itself + */ + public GetTenantPackageResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } GetTenantPackageResponse getTenantPackageResponse = (GetTenantPackageResponse) o; return Objects.equals(this.status, getTenantPackageResponse.status) && - Objects.equals(this.tenantPackage, getTenantPackageResponse.tenantPackage); + Objects.equals(this.tenantPackage, getTenantPackageResponse.tenantPackage)&& + Objects.equals(this.additionalProperties, getTenantPackageResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, tenantPackage); + return Objects.hash(status, tenantPackage, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class GetTenantPackageResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" tenantPackage: ").append(toIndentedString(tenantPackage)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetTenantPackageResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetTenantPackageResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetTenantPackageResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetTenantPackageResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, GetTenantPackageResponse value) throws IOExcep public GetTenantPackageResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetTenantPackageResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetTenantPackagesResponse.java b/client/src/main/java/com/fastcomments/model/GetTenantPackagesResponse.java index 20b1674f..e0a30839 100644 --- a/client/src/main/java/com/fastcomments/model/GetTenantPackagesResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetTenantPackagesResponse.java @@ -112,6 +112,50 @@ public void setTenantPackages(@javax.annotation.Nonnull List tena this.tenantPackages = tenantPackages; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetTenantPackagesResponse instance itself + */ + public GetTenantPackagesResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetTenantPackagesResponse getTenantPackagesResponse = (GetTenantPackagesResponse) o; return Objects.equals(this.status, getTenantPackagesResponse.status) && - Objects.equals(this.tenantPackages, getTenantPackagesResponse.tenantPackages); + Objects.equals(this.tenantPackages, getTenantPackagesResponse.tenantPackages)&& + Objects.equals(this.additionalProperties, getTenantPackagesResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, tenantPackages); + return Objects.hash(status, tenantPackages, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetTenantPackagesResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" tenantPackages: ").append(toIndentedString(tenantPackages)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetTenantPackagesResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetTenantPackagesResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetTenantPackagesResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetTenantPackagesResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetTenantPackagesResponse value) throws IOExce public GetTenantPackagesResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetTenantPackagesResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetTenantResponse.java b/client/src/main/java/com/fastcomments/model/GetTenantResponse.java index f4c99ac4..e0058833 100644 --- a/client/src/main/java/com/fastcomments/model/GetTenantResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetTenantResponse.java @@ -102,6 +102,50 @@ public void setTenant(@javax.annotation.Nonnull APITenant tenant) { this.tenant = tenant; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetTenantResponse instance itself + */ + public GetTenantResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } GetTenantResponse getTenantResponse = (GetTenantResponse) o; return Objects.equals(this.status, getTenantResponse.status) && - Objects.equals(this.tenant, getTenantResponse.tenant); + Objects.equals(this.tenant, getTenantResponse.tenant)&& + Objects.equals(this.additionalProperties, getTenantResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, tenant); + return Objects.hash(status, tenant, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class GetTenantResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" tenant: ").append(toIndentedString(tenant)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetTenantResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetTenantResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetTenantResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetTenantResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, GetTenantResponse value) throws IOException { public GetTenantResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetTenantResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetTenantUserResponse.java b/client/src/main/java/com/fastcomments/model/GetTenantUserResponse.java index b2038b00..df861934 100644 --- a/client/src/main/java/com/fastcomments/model/GetTenantUserResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetTenantUserResponse.java @@ -102,6 +102,50 @@ public void setTenantUser(@javax.annotation.Nonnull User tenantUser) { this.tenantUser = tenantUser; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetTenantUserResponse instance itself + */ + public GetTenantUserResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } GetTenantUserResponse getTenantUserResponse = (GetTenantUserResponse) o; return Objects.equals(this.status, getTenantUserResponse.status) && - Objects.equals(this.tenantUser, getTenantUserResponse.tenantUser); + Objects.equals(this.tenantUser, getTenantUserResponse.tenantUser)&& + Objects.equals(this.additionalProperties, getTenantUserResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, tenantUser); + return Objects.hash(status, tenantUser, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class GetTenantUserResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" tenantUser: ").append(toIndentedString(tenantUser)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetTenantUserResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetTenantUserResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetTenantUserResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetTenantUserResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, GetTenantUserResponse value) throws IOExceptio public GetTenantUserResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetTenantUserResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetTenantUsersResponse.java b/client/src/main/java/com/fastcomments/model/GetTenantUsersResponse.java index 9ab7cebf..0af7e27c 100644 --- a/client/src/main/java/com/fastcomments/model/GetTenantUsersResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetTenantUsersResponse.java @@ -112,6 +112,50 @@ public void setTenantUsers(@javax.annotation.Nonnull List tenantUsers) { this.tenantUsers = tenantUsers; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetTenantUsersResponse instance itself + */ + public GetTenantUsersResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetTenantUsersResponse getTenantUsersResponse = (GetTenantUsersResponse) o; return Objects.equals(this.status, getTenantUsersResponse.status) && - Objects.equals(this.tenantUsers, getTenantUsersResponse.tenantUsers); + Objects.equals(this.tenantUsers, getTenantUsersResponse.tenantUsers)&& + Objects.equals(this.additionalProperties, getTenantUsersResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, tenantUsers); + return Objects.hash(status, tenantUsers, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetTenantUsersResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" tenantUsers: ").append(toIndentedString(tenantUsers)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetTenantUsersResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetTenantUsersResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetTenantUsersResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetTenantUsersResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetTenantUsersResponse value) throws IOExcepti public GetTenantUsersResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetTenantUsersResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetTenantsResponse.java b/client/src/main/java/com/fastcomments/model/GetTenantsResponse.java index 5d124fbb..6e55b1c6 100644 --- a/client/src/main/java/com/fastcomments/model/GetTenantsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetTenantsResponse.java @@ -112,6 +112,50 @@ public void setTenants(@javax.annotation.Nonnull List tenants) { this.tenants = tenants; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetTenantsResponse instance itself + */ + public GetTenantsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetTenantsResponse getTenantsResponse = (GetTenantsResponse) o; return Objects.equals(this.status, getTenantsResponse.status) && - Objects.equals(this.tenants, getTenantsResponse.tenants); + Objects.equals(this.tenants, getTenantsResponse.tenants)&& + Objects.equals(this.additionalProperties, getTenantsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, tenants); + return Objects.hash(status, tenants, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetTenantsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" tenants: ").append(toIndentedString(tenants)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetTenantsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetTenantsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetTenantsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetTenantsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetTenantsResponse value) throws IOException { public GetTenantsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetTenantsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetTicketResponse.java b/client/src/main/java/com/fastcomments/model/GetTicketResponse.java index 06378321..d5b8e75c 100644 --- a/client/src/main/java/com/fastcomments/model/GetTicketResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetTicketResponse.java @@ -136,6 +136,50 @@ public void setAvailableStates(@javax.annotation.Nonnull List availableS this.availableStates = availableStates; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetTicketResponse instance itself + */ + public GetTicketResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -149,12 +193,13 @@ public boolean equals(Object o) { GetTicketResponse getTicketResponse = (GetTicketResponse) o; return Objects.equals(this.status, getTicketResponse.status) && Objects.equals(this.ticket, getTicketResponse.ticket) && - Objects.equals(this.availableStates, getTicketResponse.availableStates); + Objects.equals(this.availableStates, getTicketResponse.availableStates)&& + Objects.equals(this.additionalProperties, getTicketResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, ticket, availableStates); + return Objects.hash(status, ticket, availableStates, additionalProperties); } @Override @@ -164,6 +209,7 @@ public String toString() { sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" ticket: ").append(toIndentedString(ticket)).append("\n"); sb.append(" availableStates: ").append(toIndentedString(availableStates)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -201,14 +247,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetTicketResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetTicketResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetTicketResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -243,6 +281,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetTicketResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -250,7 +310,28 @@ public void write(JsonWriter out, GetTicketResponse value) throws IOException { public GetTicketResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetTicketResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetTicketsResponse.java b/client/src/main/java/com/fastcomments/model/GetTicketsResponse.java index f8e7b23a..841a455e 100644 --- a/client/src/main/java/com/fastcomments/model/GetTicketsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetTicketsResponse.java @@ -112,6 +112,50 @@ public void setTickets(@javax.annotation.Nonnull List tickets) { this.tickets = tickets; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetTicketsResponse instance itself + */ + public GetTicketsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetTicketsResponse getTicketsResponse = (GetTicketsResponse) o; return Objects.equals(this.status, getTicketsResponse.status) && - Objects.equals(this.tickets, getTicketsResponse.tickets); + Objects.equals(this.tickets, getTicketsResponse.tickets)&& + Objects.equals(this.additionalProperties, getTicketsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, tickets); + return Objects.hash(status, tickets, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetTicketsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" tickets: ").append(toIndentedString(tickets)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetTicketsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetTicketsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetTicketsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetTicketsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetTicketsResponse value) throws IOException { public GetTicketsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetTicketsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetUserNotificationCountResponse.java b/client/src/main/java/com/fastcomments/model/GetUserNotificationCountResponse.java index 62ce47ef..2f0cae84 100644 --- a/client/src/main/java/com/fastcomments/model/GetUserNotificationCountResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetUserNotificationCountResponse.java @@ -101,6 +101,50 @@ public void setCount(@javax.annotation.Nonnull Long count) { this.count = count; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetUserNotificationCountResponse instance itself + */ + public GetUserNotificationCountResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -113,12 +157,13 @@ public boolean equals(Object o) { } GetUserNotificationCountResponse getUserNotificationCountResponse = (GetUserNotificationCountResponse) o; return Objects.equals(this.status, getUserNotificationCountResponse.status) && - Objects.equals(this.count, getUserNotificationCountResponse.count); + Objects.equals(this.count, getUserNotificationCountResponse.count)&& + Objects.equals(this.additionalProperties, getUserNotificationCountResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, count); + return Objects.hash(status, count, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class GetUserNotificationCountResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -164,14 +210,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetUserNotificationCountResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetUserNotificationCountResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetUserNotificationCountResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -198,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetUserNotificationCountResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,7 +265,28 @@ public void write(JsonWriter out, GetUserNotificationCountResponse value) throws public GetUserNotificationCountResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetUserNotificationCountResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetUserResponse.java b/client/src/main/java/com/fastcomments/model/GetUserResponse.java index fac4e271..89e2810a 100644 --- a/client/src/main/java/com/fastcomments/model/GetUserResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetUserResponse.java @@ -102,6 +102,50 @@ public void setUser(@javax.annotation.Nonnull User user) { this.user = user; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetUserResponse instance itself + */ + public GetUserResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } GetUserResponse getUserResponse = (GetUserResponse) o; return Objects.equals(this.status, getUserResponse.status) && - Objects.equals(this.user, getUserResponse.user); + Objects.equals(this.user, getUserResponse.user)&& + Objects.equals(this.additionalProperties, getUserResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, user); + return Objects.hash(status, user, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class GetUserResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetUserResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetUserResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetUserResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetUserResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, GetUserResponse value) throws IOException { public GetUserResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetUserResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetVotesForUserResponse.java b/client/src/main/java/com/fastcomments/model/GetVotesForUserResponse.java index 1da7558b..daa99413 100644 --- a/client/src/main/java/com/fastcomments/model/GetVotesForUserResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetVotesForUserResponse.java @@ -176,6 +176,50 @@ public void setPendingVotes(@javax.annotation.Nonnull List pendingVo this.pendingVotes = pendingVotes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetVotesForUserResponse instance itself + */ + public GetVotesForUserResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -190,12 +234,13 @@ public boolean equals(Object o) { return Objects.equals(this.status, getVotesForUserResponse.status) && Objects.equals(this.appliedAuthorizedVotes, getVotesForUserResponse.appliedAuthorizedVotes) && Objects.equals(this.appliedAnonymousVotes, getVotesForUserResponse.appliedAnonymousVotes) && - Objects.equals(this.pendingVotes, getVotesForUserResponse.pendingVotes); + Objects.equals(this.pendingVotes, getVotesForUserResponse.pendingVotes)&& + Objects.equals(this.additionalProperties, getVotesForUserResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, appliedAuthorizedVotes, appliedAnonymousVotes, pendingVotes); + return Objects.hash(status, appliedAuthorizedVotes, appliedAnonymousVotes, pendingVotes, additionalProperties); } @Override @@ -206,6 +251,7 @@ public String toString() { sb.append(" appliedAuthorizedVotes: ").append(toIndentedString(appliedAuthorizedVotes)).append("\n"); sb.append(" appliedAnonymousVotes: ").append(toIndentedString(appliedAnonymousVotes)).append("\n"); sb.append(" pendingVotes: ").append(toIndentedString(pendingVotes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -243,14 +289,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetVotesForUserResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetVotesForUserResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetVotesForUserResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -307,6 +345,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetVotesForUserResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -314,7 +374,28 @@ public void write(JsonWriter out, GetVotesForUserResponse value) throws IOExcept public GetVotesForUserResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetVotesForUserResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetVotesResponse.java b/client/src/main/java/com/fastcomments/model/GetVotesResponse.java index a14acb06..3e968ab2 100644 --- a/client/src/main/java/com/fastcomments/model/GetVotesResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetVotesResponse.java @@ -176,6 +176,50 @@ public void setPendingVotes(@javax.annotation.Nonnull List pendingVo this.pendingVotes = pendingVotes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetVotesResponse instance itself + */ + public GetVotesResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -190,12 +234,13 @@ public boolean equals(Object o) { return Objects.equals(this.status, getVotesResponse.status) && Objects.equals(this.appliedAuthorizedVotes, getVotesResponse.appliedAuthorizedVotes) && Objects.equals(this.appliedAnonymousVotes, getVotesResponse.appliedAnonymousVotes) && - Objects.equals(this.pendingVotes, getVotesResponse.pendingVotes); + Objects.equals(this.pendingVotes, getVotesResponse.pendingVotes)&& + Objects.equals(this.additionalProperties, getVotesResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, appliedAuthorizedVotes, appliedAnonymousVotes, pendingVotes); + return Objects.hash(status, appliedAuthorizedVotes, appliedAnonymousVotes, pendingVotes, additionalProperties); } @Override @@ -206,6 +251,7 @@ public String toString() { sb.append(" appliedAuthorizedVotes: ").append(toIndentedString(appliedAuthorizedVotes)).append("\n"); sb.append(" appliedAnonymousVotes: ").append(toIndentedString(appliedAnonymousVotes)).append("\n"); sb.append(" pendingVotes: ").append(toIndentedString(pendingVotes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -243,14 +289,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetVotesResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetVotesResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetVotesResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -307,6 +345,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetVotesResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -314,7 +374,28 @@ public void write(JsonWriter out, GetVotesResponse value) throws IOException { public GetVotesResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetVotesResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetWebhookSamplePayloadsResponse.java b/client/src/main/java/com/fastcomments/model/GetWebhookSamplePayloadsResponse.java index 3bc521e7..2738969d 100644 --- a/client/src/main/java/com/fastcomments/model/GetWebhookSamplePayloadsResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetWebhookSamplePayloadsResponse.java @@ -112,6 +112,50 @@ public void setPayloads(@javax.annotation.Nonnull List payloads) this.payloads = payloads; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetWebhookSamplePayloadsResponse instance itself + */ + public GetWebhookSamplePayloadsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetWebhookSamplePayloadsResponse getWebhookSamplePayloadsResponse = (GetWebhookSamplePayloadsResponse) o; return Objects.equals(this.status, getWebhookSamplePayloadsResponse.status) && - Objects.equals(this.payloads, getWebhookSamplePayloadsResponse.payloads); + Objects.equals(this.payloads, getWebhookSamplePayloadsResponse.payloads)&& + Objects.equals(this.additionalProperties, getWebhookSamplePayloadsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, payloads); + return Objects.hash(status, payloads, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetWebhookSamplePayloadsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" payloads: ").append(toIndentedString(payloads)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetWebhookSamplePayloadsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetWebhookSamplePayloadsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetWebhookSamplePayloadsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetWebhookSamplePayloadsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetWebhookSamplePayloadsResponse value) throws public GetWebhookSamplePayloadsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetWebhookSamplePayloadsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/GetWebhooksResponse.java b/client/src/main/java/com/fastcomments/model/GetWebhooksResponse.java index 8a4be650..4801e6cc 100644 --- a/client/src/main/java/com/fastcomments/model/GetWebhooksResponse.java +++ b/client/src/main/java/com/fastcomments/model/GetWebhooksResponse.java @@ -112,6 +112,50 @@ public void setWebhooks(@javax.annotation.Nonnull List webhooks) this.webhooks = webhooks; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GetWebhooksResponse instance itself + */ + public GetWebhooksResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } GetWebhooksResponse getWebhooksResponse = (GetWebhooksResponse) o; return Objects.equals(this.status, getWebhooksResponse.status) && - Objects.equals(this.webhooks, getWebhooksResponse.webhooks); + Objects.equals(this.webhooks, getWebhooksResponse.webhooks)&& + Objects.equals(this.additionalProperties, getWebhooksResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, webhooks); + return Objects.hash(status, webhooks, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class GetWebhooksResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" webhooks: ").append(toIndentedString(webhooks)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetWebhooksResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetWebhooksResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetWebhooksResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetWebhooksResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, GetWebhooksResponse value) throws IOException public GetWebhooksResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetWebhooksResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/HeaderAccountNotification.java b/client/src/main/java/com/fastcomments/model/HeaderAccountNotification.java index 1007b506..6c4a14a5 100644 --- a/client/src/main/java/com/fastcomments/model/HeaderAccountNotification.java +++ b/client/src/main/java/com/fastcomments/model/HeaderAccountNotification.java @@ -311,6 +311,50 @@ public void setType(@javax.annotation.Nullable String type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the HeaderAccountNotification instance itself + */ + public HeaderAccountNotification putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -331,12 +375,13 @@ public boolean equals(Object o) { Objects.equals(this.linkUrl, headerAccountNotification.linkUrl) && Objects.equals(this.linkText, headerAccountNotification.linkText) && Objects.equals(this.createdAt, headerAccountNotification.createdAt) && - Objects.equals(this.type, headerAccountNotification.type); + Objects.equals(this.type, headerAccountNotification.type)&& + Objects.equals(this.additionalProperties, headerAccountNotification.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, title, message, messagesByLocale, dates, severity, linkUrl, linkText, createdAt, type); + return Objects.hash(id, title, message, messagesByLocale, dates, severity, linkUrl, linkText, createdAt, type, additionalProperties); } @Override @@ -353,6 +398,7 @@ public String toString() { sb.append(" linkText: ").append(toIndentedString(linkText)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -390,14 +436,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!HeaderAccountNotification.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `HeaderAccountNotification` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : HeaderAccountNotification.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -443,6 +481,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, HeaderAccountNotification value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -450,7 +510,28 @@ public void write(JsonWriter out, HeaderAccountNotification value) throws IOExce public HeaderAccountNotification read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + HeaderAccountNotification instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/HeaderState.java b/client/src/main/java/com/fastcomments/model/HeaderState.java index 54f6b216..cf88b521 100644 --- a/client/src/main/java/com/fastcomments/model/HeaderState.java +++ b/client/src/main/java/com/fastcomments/model/HeaderState.java @@ -217,6 +217,50 @@ public void setAccountNotifications(@javax.annotation.Nonnull List additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the HeaderState instance itself + */ + public HeaderState putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -233,12 +277,13 @@ public boolean equals(Object o) { Objects.equals(this.userId, headerState.userId) && Objects.equals(this.userIdWS, headerState.userIdWS) && Objects.equals(this.notificationCounts, headerState.notificationCounts) && - Objects.equals(this.accountNotifications, headerState.accountNotifications); + Objects.equals(this.accountNotifications, headerState.accountNotifications)&& + Objects.equals(this.additionalProperties, headerState.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, notificationType, userId, userIdWS, notificationCounts, accountNotifications); + return Objects.hash(status, notificationType, userId, userIdWS, notificationCounts, accountNotifications, additionalProperties); } @Override @@ -251,6 +296,7 @@ public String toString() { sb.append(" userIdWS: ").append(toIndentedString(userIdWS)).append("\n"); sb.append(" notificationCounts: ").append(toIndentedString(notificationCounts)).append("\n"); sb.append(" accountNotifications: ").append(toIndentedString(accountNotifications)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -288,14 +334,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!HeaderState.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `HeaderState` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : HeaderState.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -348,6 +386,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, HeaderState value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -355,7 +415,28 @@ public void write(JsonWriter out, HeaderState value) throws IOException { public HeaderState read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + HeaderState instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/IgnoredResponse.java b/client/src/main/java/com/fastcomments/model/IgnoredResponse.java index e1c76c3d..64527620 100644 --- a/client/src/main/java/com/fastcomments/model/IgnoredResponse.java +++ b/client/src/main/java/com/fastcomments/model/IgnoredResponse.java @@ -153,6 +153,50 @@ public void setNote(@javax.annotation.Nonnull NoteEnum note) { this.note = note; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the IgnoredResponse instance itself + */ + public IgnoredResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -165,12 +209,13 @@ public boolean equals(Object o) { } IgnoredResponse ignoredResponse = (IgnoredResponse) o; return Objects.equals(this.status, ignoredResponse.status) && - Objects.equals(this.note, ignoredResponse.note); + Objects.equals(this.note, ignoredResponse.note)&& + Objects.equals(this.additionalProperties, ignoredResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, note); + return Objects.hash(status, note, additionalProperties); } @Override @@ -179,6 +224,7 @@ public String toString() { sb.append("class IgnoredResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" note: ").append(toIndentedString(note)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -216,14 +262,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!IgnoredResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `IgnoredResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : IgnoredResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -255,6 +293,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, IgnoredResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -262,7 +322,28 @@ public void write(JsonWriter out, IgnoredResponse value) throws IOException { public IgnoredResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + IgnoredResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/LiveEvent.java b/client/src/main/java/com/fastcomments/model/LiveEvent.java index a520466d..7de2b76e 100644 --- a/client/src/main/java/com/fastcomments/model/LiveEvent.java +++ b/client/src/main/java/com/fastcomments/model/LiveEvent.java @@ -552,6 +552,50 @@ public void setChanges(@javax.annotation.Nullable Map changes) this.changes = changes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the LiveEvent instance itself + */ + public LiveEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -581,12 +625,13 @@ public boolean equals(Object o) { Objects.equals(this.uj, liveEvent.uj) && Objects.equals(this.ul, liveEvent.ul) && Objects.equals(this.sc, liveEvent.sc) && - Objects.equals(this.changes, liveEvent.changes); + Objects.equals(this.changes, liveEvent.changes)&& + Objects.equals(this.additionalProperties, liveEvent.additionalProperties); } @Override public int hashCode() { - return Objects.hash(type, timestamp, ts, broadcastId, userId, badges, notification, vote, comment, feedPost, commentId, poll, extraInfo, config, isClosed, uj, ul, sc, changes); + return Objects.hash(type, timestamp, ts, broadcastId, userId, badges, notification, vote, comment, feedPost, commentId, poll, extraInfo, config, isClosed, uj, ul, sc, changes, additionalProperties); } @Override @@ -612,6 +657,7 @@ public String toString() { sb.append(" ul: ").append(toIndentedString(ul)).append("\n"); sb.append(" sc: ").append(toIndentedString(sc)).append("\n"); sb.append(" changes: ").append(toIndentedString(changes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -649,14 +695,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!LiveEvent.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `LiveEvent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : LiveEvent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -738,6 +776,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, LiveEvent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -745,7 +805,28 @@ public void write(JsonWriter out, LiveEvent value) throws IOException { public LiveEvent read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + LiveEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/MediaAsset.java b/client/src/main/java/com/fastcomments/model/MediaAsset.java index 39e9d57e..bda03d14 100644 --- a/client/src/main/java/com/fastcomments/model/MediaAsset.java +++ b/client/src/main/java/com/fastcomments/model/MediaAsset.java @@ -124,6 +124,50 @@ public void setSrc(@javax.annotation.Nonnull String src) { this.src = src; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MediaAsset instance itself + */ + public MediaAsset putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -137,12 +181,13 @@ public boolean equals(Object o) { MediaAsset mediaAsset = (MediaAsset) o; return Objects.equals(this.w, mediaAsset.w) && Objects.equals(this.h, mediaAsset.h) && - Objects.equals(this.src, mediaAsset.src); + Objects.equals(this.src, mediaAsset.src)&& + Objects.equals(this.additionalProperties, mediaAsset.additionalProperties); } @Override public int hashCode() { - return Objects.hash(w, h, src); + return Objects.hash(w, h, src, additionalProperties); } @Override @@ -152,6 +197,7 @@ public String toString() { sb.append(" w: ").append(toIndentedString(w)).append("\n"); sb.append(" h: ").append(toIndentedString(h)).append("\n"); sb.append(" src: ").append(toIndentedString(src)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -189,14 +235,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MediaAsset.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `MediaAsset` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : MediaAsset.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -224,6 +262,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, MediaAsset value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -231,7 +291,28 @@ public void write(JsonWriter out, MediaAsset value) throws IOException { public MediaAsset read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MediaAsset instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/MetaItem.java b/client/src/main/java/com/fastcomments/model/MetaItem.java index d6eca2e3..06f62aca 100644 --- a/client/src/main/java/com/fastcomments/model/MetaItem.java +++ b/client/src/main/java/com/fastcomments/model/MetaItem.java @@ -110,6 +110,50 @@ public void setValues(@javax.annotation.Nonnull List values) { this.values = values; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the MetaItem instance itself + */ + public MetaItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -122,12 +166,13 @@ public boolean equals(Object o) { } MetaItem metaItem = (MetaItem) o; return Objects.equals(this.name, metaItem.name) && - Objects.equals(this.values, metaItem.values); + Objects.equals(this.values, metaItem.values)&& + Objects.equals(this.additionalProperties, metaItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, values); + return Objects.hash(name, values, additionalProperties); } @Override @@ -136,6 +181,7 @@ public String toString() { sb.append("class MetaItem {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" values: ").append(toIndentedString(values)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -173,14 +219,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MetaItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `MetaItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : MetaItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -214,6 +252,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, MetaItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -221,7 +281,28 @@ public void write(JsonWriter out, MetaItem value) throws IOException { public MetaItem read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + MetaItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ModerationAPIComment.java b/client/src/main/java/com/fastcomments/model/ModerationAPIComment.java index cf2b0999..a0e82f1d 100644 --- a/client/src/main/java/com/fastcomments/model/ModerationAPIComment.java +++ b/client/src/main/java/com/fastcomments/model/ModerationAPIComment.java @@ -1088,6 +1088,50 @@ public void setIsDeleted(@javax.annotation.Nullable Boolean isDeleted) { this.isDeleted = isDeleted; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModerationAPIComment instance itself + */ + public ModerationAPIComment putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -1140,12 +1184,13 @@ public boolean equals(Object o) { Objects.equals(this.badges, moderationAPIComment.badges) && Objects.equals(this.verified, moderationAPIComment.verified) && Objects.equals(this.feedbackIds, moderationAPIComment.feedbackIds) && - Objects.equals(this.isDeleted, moderationAPIComment.isDeleted); + Objects.equals(this.isDeleted, moderationAPIComment.isDeleted)&& + Objects.equals(this.additionalProperties, moderationAPIComment.additionalProperties); } @Override public int hashCode() { - return Objects.hash(isLocalDeleted, replyCount, feedbackResults, isVotedUp, isVotedDown, myVoteId, id, tenantId, urlId, url, pageTitle, userId, anonUserId, commenterName, commenterLink, commentHTML, parentId, date, localDateString, votes, votesUp, votesDown, expireAt, reviewed, avatarSrc, isSpam, permNotSpam, hasLinks, hasCode, approved, locale, isBannedUser, isByAdmin, isByModerator, isPinned, isLocked, flagCount, displayLabel, badges, verified, feedbackIds, isDeleted); + return Objects.hash(isLocalDeleted, replyCount, feedbackResults, isVotedUp, isVotedDown, myVoteId, id, tenantId, urlId, url, pageTitle, userId, anonUserId, commenterName, commenterLink, commentHTML, parentId, date, localDateString, votes, votesUp, votesDown, expireAt, reviewed, avatarSrc, isSpam, permNotSpam, hasLinks, hasCode, approved, locale, isBannedUser, isByAdmin, isByModerator, isPinned, isLocked, flagCount, displayLabel, badges, verified, feedbackIds, isDeleted, additionalProperties); } @Override @@ -1194,6 +1239,7 @@ public String toString() { sb.append(" verified: ").append(toIndentedString(verified)).append("\n"); sb.append(" feedbackIds: ").append(toIndentedString(feedbackIds)).append("\n"); sb.append(" isDeleted: ").append(toIndentedString(isDeleted)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -1231,14 +1277,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModerationAPIComment.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModerationAPIComment` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModerationAPIComment.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -1333,6 +1371,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModerationAPIComment value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -1340,7 +1400,28 @@ public void write(JsonWriter out, ModerationAPIComment value) throws IOException public ModerationAPIComment read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModerationAPIComment instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ModerationAPICommentLog.java b/client/src/main/java/com/fastcomments/model/ModerationAPICommentLog.java index d963f29f..da9e65ba 100644 --- a/client/src/main/java/com/fastcomments/model/ModerationAPICommentLog.java +++ b/client/src/main/java/com/fastcomments/model/ModerationAPICommentLog.java @@ -149,6 +149,50 @@ public void setMessageHTML(@javax.annotation.Nonnull String messageHTML) { this.messageHTML = messageHTML; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModerationAPICommentLog instance itself + */ + public ModerationAPICommentLog putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -163,12 +207,13 @@ public boolean equals(Object o) { return Objects.equals(this.date, moderationAPICommentLog.date) && Objects.equals(this.username, moderationAPICommentLog.username) && Objects.equals(this.actionName, moderationAPICommentLog.actionName) && - Objects.equals(this.messageHTML, moderationAPICommentLog.messageHTML); + Objects.equals(this.messageHTML, moderationAPICommentLog.messageHTML)&& + Objects.equals(this.additionalProperties, moderationAPICommentLog.additionalProperties); } @Override public int hashCode() { - return Objects.hash(date, username, actionName, messageHTML); + return Objects.hash(date, username, actionName, messageHTML, additionalProperties); } @Override @@ -179,6 +224,7 @@ public String toString() { sb.append(" username: ").append(toIndentedString(username)).append("\n"); sb.append(" actionName: ").append(toIndentedString(actionName)).append("\n"); sb.append(" messageHTML: ").append(toIndentedString(messageHTML)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -216,14 +262,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModerationAPICommentLog.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModerationAPICommentLog` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModerationAPICommentLog.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -257,6 +295,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModerationAPICommentLog value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -264,7 +324,28 @@ public void write(JsonWriter out, ModerationAPICommentLog value) throws IOExcept public ModerationAPICommentLog read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModerationAPICommentLog instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ModerationAPICountCommentsResponse.java b/client/src/main/java/com/fastcomments/model/ModerationAPICountCommentsResponse.java index 3a58c493..2a254885 100644 --- a/client/src/main/java/com/fastcomments/model/ModerationAPICountCommentsResponse.java +++ b/client/src/main/java/com/fastcomments/model/ModerationAPICountCommentsResponse.java @@ -101,6 +101,50 @@ public void setCount(@javax.annotation.Nonnull Double count) { this.count = count; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModerationAPICountCommentsResponse instance itself + */ + public ModerationAPICountCommentsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -113,12 +157,13 @@ public boolean equals(Object o) { } ModerationAPICountCommentsResponse moderationAPICountCommentsResponse = (ModerationAPICountCommentsResponse) o; return Objects.equals(this.status, moderationAPICountCommentsResponse.status) && - Objects.equals(this.count, moderationAPICountCommentsResponse.count); + Objects.equals(this.count, moderationAPICountCommentsResponse.count)&& + Objects.equals(this.additionalProperties, moderationAPICountCommentsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, count); + return Objects.hash(status, count, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class ModerationAPICountCommentsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -164,14 +210,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModerationAPICountCommentsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModerationAPICountCommentsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModerationAPICountCommentsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -198,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModerationAPICountCommentsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,7 +265,28 @@ public void write(JsonWriter out, ModerationAPICountCommentsResponse value) thro public ModerationAPICountCommentsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModerationAPICountCommentsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ModerationAPIGetCommentsResponse.java b/client/src/main/java/com/fastcomments/model/ModerationAPIGetCommentsResponse.java index 9e23e5ac..110b031a 100644 --- a/client/src/main/java/com/fastcomments/model/ModerationAPIGetCommentsResponse.java +++ b/client/src/main/java/com/fastcomments/model/ModerationAPIGetCommentsResponse.java @@ -161,6 +161,50 @@ public void setModerationFilter(@javax.annotation.Nullable ModerationFilter mode this.moderationFilter = moderationFilter; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModerationAPIGetCommentsResponse instance itself + */ + public ModerationAPIGetCommentsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -175,12 +219,13 @@ public boolean equals(Object o) { return Objects.equals(this.status, moderationAPIGetCommentsResponse.status) && Objects.equals(this.translations, moderationAPIGetCommentsResponse.translations) && Objects.equals(this.comments, moderationAPIGetCommentsResponse.comments) && - Objects.equals(this.moderationFilter, moderationAPIGetCommentsResponse.moderationFilter); + Objects.equals(this.moderationFilter, moderationAPIGetCommentsResponse.moderationFilter)&& + Objects.equals(this.additionalProperties, moderationAPIGetCommentsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, translations, comments, moderationFilter); + return Objects.hash(status, translations, comments, moderationFilter, additionalProperties); } @Override @@ -191,6 +236,7 @@ public String toString() { sb.append(" translations: ").append(toIndentedString(translations)).append("\n"); sb.append(" comments: ").append(toIndentedString(comments)).append("\n"); sb.append(" moderationFilter: ").append(toIndentedString(moderationFilter)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -228,14 +274,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModerationAPIGetCommentsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModerationAPIGetCommentsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModerationAPIGetCommentsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -276,6 +314,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModerationAPIGetCommentsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -283,7 +343,28 @@ public void write(JsonWriter out, ModerationAPIGetCommentsResponse value) throws public ModerationAPIGetCommentsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModerationAPIGetCommentsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ModerationExportResponse.java b/client/src/main/java/com/fastcomments/model/ModerationExportResponse.java index b2157d11..0b82cc19 100644 --- a/client/src/main/java/com/fastcomments/model/ModerationExportResponse.java +++ b/client/src/main/java/com/fastcomments/model/ModerationExportResponse.java @@ -100,6 +100,50 @@ public void setBatchJobId(@javax.annotation.Nonnull String batchJobId) { this.batchJobId = batchJobId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModerationExportResponse instance itself + */ + public ModerationExportResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -112,12 +156,13 @@ public boolean equals(Object o) { } ModerationExportResponse moderationExportResponse = (ModerationExportResponse) o; return Objects.equals(this.status, moderationExportResponse.status) && - Objects.equals(this.batchJobId, moderationExportResponse.batchJobId); + Objects.equals(this.batchJobId, moderationExportResponse.batchJobId)&& + Objects.equals(this.additionalProperties, moderationExportResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, batchJobId); + return Objects.hash(status, batchJobId, additionalProperties); } @Override @@ -126,6 +171,7 @@ public String toString() { sb.append("class ModerationExportResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" batchJobId: ").append(toIndentedString(batchJobId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -163,14 +209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModerationExportResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModerationExportResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModerationExportResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModerationExportResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, ModerationExportResponse value) throws IOExcep public ModerationExportResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModerationExportResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ModerationExportStatusResponse.java b/client/src/main/java/com/fastcomments/model/ModerationExportStatusResponse.java index 4ab008f2..06ecdf57 100644 --- a/client/src/main/java/com/fastcomments/model/ModerationExportStatusResponse.java +++ b/client/src/main/java/com/fastcomments/model/ModerationExportStatusResponse.java @@ -148,6 +148,50 @@ public void setDownloadUrl(@javax.annotation.Nullable String downloadUrl) { this.downloadUrl = downloadUrl; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModerationExportStatusResponse instance itself + */ + public ModerationExportStatusResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -162,12 +206,13 @@ public boolean equals(Object o) { return Objects.equals(this.status, moderationExportStatusResponse.status) && Objects.equals(this.jobStatus, moderationExportStatusResponse.jobStatus) && Objects.equals(this.recordCount, moderationExportStatusResponse.recordCount) && - Objects.equals(this.downloadUrl, moderationExportStatusResponse.downloadUrl); + Objects.equals(this.downloadUrl, moderationExportStatusResponse.downloadUrl)&& + Objects.equals(this.additionalProperties, moderationExportStatusResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, jobStatus, recordCount, downloadUrl); + return Objects.hash(status, jobStatus, recordCount, downloadUrl, additionalProperties); } @Override @@ -178,6 +223,7 @@ public String toString() { sb.append(" jobStatus: ").append(toIndentedString(jobStatus)).append("\n"); sb.append(" recordCount: ").append(toIndentedString(recordCount)).append("\n"); sb.append(" downloadUrl: ").append(toIndentedString(downloadUrl)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -215,14 +261,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModerationExportStatusResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModerationExportStatusResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModerationExportStatusResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -256,6 +294,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModerationExportStatusResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -263,7 +323,28 @@ public void write(JsonWriter out, ModerationExportStatusResponse value) throws I public ModerationExportStatusResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModerationExportStatusResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ModerationFilter.java b/client/src/main/java/com/fastcomments/model/ModerationFilter.java index a1050e81..9ede8ce3 100644 --- a/client/src/main/java/com/fastcomments/model/ModerationFilter.java +++ b/client/src/main/java/com/fastcomments/model/ModerationFilter.java @@ -358,6 +358,50 @@ public void setExactCommentText(@javax.annotation.Nullable String exactCommentTe this.exactCommentText = exactCommentText; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModerationFilter instance itself + */ + public ModerationFilter putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -380,12 +424,13 @@ public boolean equals(Object o) { Objects.equals(this.domain, moderationFilter.domain) && Objects.equals(this.moderationGroupIds, moderationFilter.moderationGroupIds) && Objects.equals(this.commentTextSearch, moderationFilter.commentTextSearch) && - Objects.equals(this.exactCommentText, moderationFilter.exactCommentText); + Objects.equals(this.exactCommentText, moderationFilter.exactCommentText)&& + Objects.equals(this.additionalProperties, moderationFilter.additionalProperties); } @Override public int hashCode() { - return Objects.hash(reviewed, approved, isSpam, isBannedUser, isLocked, flagCountGt, userId, urlId, domain, moderationGroupIds, commentTextSearch, exactCommentText); + return Objects.hash(reviewed, approved, isSpam, isBannedUser, isLocked, flagCountGt, userId, urlId, domain, moderationGroupIds, commentTextSearch, exactCommentText, additionalProperties); } @Override @@ -404,6 +449,7 @@ public String toString() { sb.append(" moderationGroupIds: ").append(toIndentedString(moderationGroupIds)).append("\n"); sb.append(" commentTextSearch: ").append(toIndentedString(commentTextSearch)).append("\n"); sb.append(" exactCommentText: ").append(toIndentedString(exactCommentText)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -440,14 +486,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ModerationFilter is not found in the empty JSON string", ModerationFilter.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModerationFilter.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModerationFilter` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("userId") != null && !jsonObj.get("userId").isJsonNull()) && !jsonObj.get("userId").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `userId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("userId").toString())); @@ -486,6 +524,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModerationFilter value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -493,7 +553,28 @@ public void write(JsonWriter out, ModerationFilter value) throws IOException { public ModerationFilter read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModerationFilter instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ModerationPageSearchProjected.java b/client/src/main/java/com/fastcomments/model/ModerationPageSearchProjected.java index 4f5e849b..79fdb85a 100644 --- a/client/src/main/java/com/fastcomments/model/ModerationPageSearchProjected.java +++ b/client/src/main/java/com/fastcomments/model/ModerationPageSearchProjected.java @@ -148,6 +148,50 @@ public void setCommentCount(@javax.annotation.Nonnull Double commentCount) { this.commentCount = commentCount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModerationPageSearchProjected instance itself + */ + public ModerationPageSearchProjected putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -162,12 +206,13 @@ public boolean equals(Object o) { return Objects.equals(this.urlId, moderationPageSearchProjected.urlId) && Objects.equals(this.url, moderationPageSearchProjected.url) && Objects.equals(this.title, moderationPageSearchProjected.title) && - Objects.equals(this.commentCount, moderationPageSearchProjected.commentCount); + Objects.equals(this.commentCount, moderationPageSearchProjected.commentCount)&& + Objects.equals(this.additionalProperties, moderationPageSearchProjected.additionalProperties); } @Override public int hashCode() { - return Objects.hash(urlId, url, title, commentCount); + return Objects.hash(urlId, url, title, commentCount, additionalProperties); } @Override @@ -178,6 +223,7 @@ public String toString() { sb.append(" url: ").append(toIndentedString(url)).append("\n"); sb.append(" title: ").append(toIndentedString(title)).append("\n"); sb.append(" commentCount: ").append(toIndentedString(commentCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -215,14 +261,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModerationPageSearchProjected.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModerationPageSearchProjected` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModerationPageSearchProjected.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -256,6 +294,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModerationPageSearchProjected value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -263,7 +323,28 @@ public void write(JsonWriter out, ModerationPageSearchProjected value) throws IO public ModerationPageSearchProjected read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModerationPageSearchProjected instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ModerationSiteSearchProjected.java b/client/src/main/java/com/fastcomments/model/ModerationSiteSearchProjected.java index 3a2894c6..48fb4ab6 100644 --- a/client/src/main/java/com/fastcomments/model/ModerationSiteSearchProjected.java +++ b/client/src/main/java/com/fastcomments/model/ModerationSiteSearchProjected.java @@ -100,6 +100,50 @@ public void setLogoSrc100px(@javax.annotation.Nullable String logoSrc100px) { this.logoSrc100px = logoSrc100px; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModerationSiteSearchProjected instance itself + */ + public ModerationSiteSearchProjected putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -112,12 +156,13 @@ public boolean equals(Object o) { } ModerationSiteSearchProjected moderationSiteSearchProjected = (ModerationSiteSearchProjected) o; return Objects.equals(this.domain, moderationSiteSearchProjected.domain) && - Objects.equals(this.logoSrc100px, moderationSiteSearchProjected.logoSrc100px); + Objects.equals(this.logoSrc100px, moderationSiteSearchProjected.logoSrc100px)&& + Objects.equals(this.additionalProperties, moderationSiteSearchProjected.additionalProperties); } @Override public int hashCode() { - return Objects.hash(domain, logoSrc100px); + return Objects.hash(domain, logoSrc100px, additionalProperties); } @Override @@ -126,6 +171,7 @@ public String toString() { sb.append("class ModerationSiteSearchProjected {\n"); sb.append(" domain: ").append(toIndentedString(domain)).append("\n"); sb.append(" logoSrc100px: ").append(toIndentedString(logoSrc100px)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -163,14 +209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModerationSiteSearchProjected.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModerationSiteSearchProjected` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModerationSiteSearchProjected.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModerationSiteSearchProjected value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, ModerationSiteSearchProjected value) throws IO public ModerationSiteSearchProjected read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModerationSiteSearchProjected instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ModerationSuggestResponse.java b/client/src/main/java/com/fastcomments/model/ModerationSuggestResponse.java index 389ede77..26379347 100644 --- a/client/src/main/java/com/fastcomments/model/ModerationSuggestResponse.java +++ b/client/src/main/java/com/fastcomments/model/ModerationSuggestResponse.java @@ -168,6 +168,50 @@ public void setCode(@javax.annotation.Nullable String code) { this.code = code; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModerationSuggestResponse instance itself + */ + public ModerationSuggestResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -182,12 +226,13 @@ public boolean equals(Object o) { return Objects.equals(this.status, moderationSuggestResponse.status) && Objects.equals(this.pages, moderationSuggestResponse.pages) && Objects.equals(this.users, moderationSuggestResponse.users) && - Objects.equals(this.code, moderationSuggestResponse.code); + Objects.equals(this.code, moderationSuggestResponse.code)&& + Objects.equals(this.additionalProperties, moderationSuggestResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, pages, users, code); + return Objects.hash(status, pages, users, code, additionalProperties); } @Override @@ -198,6 +243,7 @@ public String toString() { sb.append(" pages: ").append(toIndentedString(pages)).append("\n"); sb.append(" users: ").append(toIndentedString(users)).append("\n"); sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -235,14 +281,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModerationSuggestResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModerationSuggestResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModerationSuggestResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -301,6 +339,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModerationSuggestResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -308,7 +368,28 @@ public void write(JsonWriter out, ModerationSuggestResponse value) throws IOExce public ModerationSuggestResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModerationSuggestResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ModerationUserSearchProjected.java b/client/src/main/java/com/fastcomments/model/ModerationUserSearchProjected.java index 53c44dfe..d37457da 100644 --- a/client/src/main/java/com/fastcomments/model/ModerationUserSearchProjected.java +++ b/client/src/main/java/com/fastcomments/model/ModerationUserSearchProjected.java @@ -148,6 +148,50 @@ public void setAvatarSrc(@javax.annotation.Nullable String avatarSrc) { this.avatarSrc = avatarSrc; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ModerationUserSearchProjected instance itself + */ + public ModerationUserSearchProjected putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -162,12 +206,13 @@ public boolean equals(Object o) { return Objects.equals(this.id, moderationUserSearchProjected.id) && Objects.equals(this.username, moderationUserSearchProjected.username) && Objects.equals(this.displayName, moderationUserSearchProjected.displayName) && - Objects.equals(this.avatarSrc, moderationUserSearchProjected.avatarSrc); + Objects.equals(this.avatarSrc, moderationUserSearchProjected.avatarSrc)&& + Objects.equals(this.additionalProperties, moderationUserSearchProjected.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, username, displayName, avatarSrc); + return Objects.hash(id, username, displayName, avatarSrc, additionalProperties); } @Override @@ -178,6 +223,7 @@ public String toString() { sb.append(" username: ").append(toIndentedString(username)).append("\n"); sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); sb.append(" avatarSrc: ").append(toIndentedString(avatarSrc)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -215,14 +261,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModerationUserSearchProjected.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModerationUserSearchProjected` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModerationUserSearchProjected.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -259,6 +297,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModerationUserSearchProjected value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -266,7 +326,28 @@ public void write(JsonWriter out, ModerationUserSearchProjected value) throws IO public ModerationUserSearchProjected read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ModerationUserSearchProjected instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/Moderator.java b/client/src/main/java/com/fastcomments/model/Moderator.java index 19c44bcf..6a248a2d 100644 --- a/client/src/main/java/com/fastcomments/model/Moderator.java +++ b/client/src/main/java/com/fastcomments/model/Moderator.java @@ -519,6 +519,50 @@ public void setIsEmailSuppressed(@javax.annotation.Nullable Boolean isEmailSuppr this.isEmailSuppressed = isEmailSuppressed; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Moderator instance itself + */ + public Moderator putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -548,12 +592,13 @@ public boolean equals(Object o) { Objects.equals(this.verificationId, moderator.verificationId) && Objects.equals(this.createdAt, moderator.createdAt) && Objects.equals(this.moderationGroupIds, moderator.moderationGroupIds) && - Objects.equals(this.isEmailSuppressed, moderator.isEmailSuppressed); + Objects.equals(this.isEmailSuppressed, moderator.isEmailSuppressed)&& + Objects.equals(this.additionalProperties, moderator.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, name, userId, acceptedInvite, email, markReviewedCount, deletedCount, markedSpamCount, markedNotSpamCount, approvedCount, unApprovedCount, editedCount, bannedCount, unFlaggedCount, verificationId, createdAt, moderationGroupIds, isEmailSuppressed); + return Objects.hash(id, tenantId, name, userId, acceptedInvite, email, markReviewedCount, deletedCount, markedSpamCount, markedNotSpamCount, approvedCount, unApprovedCount, editedCount, bannedCount, unFlaggedCount, verificationId, createdAt, moderationGroupIds, isEmailSuppressed, additionalProperties); } @Override @@ -579,6 +624,7 @@ public String toString() { sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); sb.append(" moderationGroupIds: ").append(toIndentedString(moderationGroupIds)).append("\n"); sb.append(" isEmailSuppressed: ").append(toIndentedString(isEmailSuppressed)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -616,14 +662,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Moderator.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Moderator` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Moderator.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -672,6 +710,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Moderator value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -679,7 +739,28 @@ public void write(JsonWriter out, Moderator value) throws IOException { public Moderator read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Moderator instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/NotificationAndCount.java b/client/src/main/java/com/fastcomments/model/NotificationAndCount.java index 6877a300..2a271bfa 100644 --- a/client/src/main/java/com/fastcomments/model/NotificationAndCount.java +++ b/client/src/main/java/com/fastcomments/model/NotificationAndCount.java @@ -101,6 +101,50 @@ public void setCount(@javax.annotation.Nonnull Long count) { this.count = count; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the NotificationAndCount instance itself + */ + public NotificationAndCount putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -113,12 +157,13 @@ public boolean equals(Object o) { } NotificationAndCount notificationAndCount = (NotificationAndCount) o; return Objects.equals(this.type, notificationAndCount.type) && - Objects.equals(this.count, notificationAndCount.count); + Objects.equals(this.count, notificationAndCount.count)&& + Objects.equals(this.additionalProperties, notificationAndCount.additionalProperties); } @Override public int hashCode() { - return Objects.hash(type, count); + return Objects.hash(type, count, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class NotificationAndCount {\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -164,14 +210,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!NotificationAndCount.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `NotificationAndCount` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : NotificationAndCount.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -198,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, NotificationAndCount value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,7 +265,28 @@ public void write(JsonWriter out, NotificationAndCount value) throws IOException public NotificationAndCount read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NotificationAndCount instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PageMigration.java b/client/src/main/java/com/fastcomments/model/PageMigration.java index 43972f3e..ad6b7849 100644 --- a/client/src/main/java/com/fastcomments/model/PageMigration.java +++ b/client/src/main/java/com/fastcomments/model/PageMigration.java @@ -125,6 +125,50 @@ public void setType(@javax.annotation.Nonnull PageMigrationType type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PageMigration instance itself + */ + public PageMigration putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -138,12 +182,13 @@ public boolean equals(Object o) { PageMigration pageMigration = (PageMigration) o; return Objects.equals(this.from, pageMigration.from) && Objects.equals(this.to, pageMigration.to) && - Objects.equals(this.type, pageMigration.type); + Objects.equals(this.type, pageMigration.type)&& + Objects.equals(this.additionalProperties, pageMigration.additionalProperties); } @Override public int hashCode() { - return Objects.hash(from, to, type); + return Objects.hash(from, to, type, additionalProperties); } @Override @@ -153,6 +198,7 @@ public String toString() { sb.append(" from: ").append(toIndentedString(from)).append("\n"); sb.append(" to: ").append(toIndentedString(to)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -190,14 +236,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PageMigration.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PageMigration` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PageMigration.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -230,6 +268,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PageMigration value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -237,7 +297,28 @@ public void write(JsonWriter out, PageMigration value) throws IOException { public PageMigration read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PageMigration instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PageMigrationFailure.java b/client/src/main/java/com/fastcomments/model/PageMigrationFailure.java index 0e7784d6..3871f5bf 100644 --- a/client/src/main/java/com/fastcomments/model/PageMigrationFailure.java +++ b/client/src/main/java/com/fastcomments/model/PageMigrationFailure.java @@ -198,6 +198,50 @@ public void setReason(@javax.annotation.Nonnull String reason) { this.reason = reason; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PageMigrationFailure instance itself + */ + public PageMigrationFailure putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -214,12 +258,13 @@ public boolean equals(Object o) { Objects.equals(this.type, pageMigrationFailure.type) && Objects.equals(this.status, pageMigrationFailure.status) && Objects.equals(this.code, pageMigrationFailure.code) && - Objects.equals(this.reason, pageMigrationFailure.reason); + Objects.equals(this.reason, pageMigrationFailure.reason)&& + Objects.equals(this.additionalProperties, pageMigrationFailure.additionalProperties); } @Override public int hashCode() { - return Objects.hash(from, to, type, status, code, reason); + return Objects.hash(from, to, type, status, code, reason, additionalProperties); } @Override @@ -232,6 +277,7 @@ public String toString() { sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" code: ").append(toIndentedString(code)).append("\n"); sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PageMigrationFailure.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PageMigrationFailure` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PageMigrationFailure.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -317,6 +355,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PageMigrationFailure value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -324,7 +384,28 @@ public void write(JsonWriter out, PageMigrationFailure value) throws IOException public PageMigrationFailure read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PageMigrationFailure instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PageMigrationSuccess.java b/client/src/main/java/com/fastcomments/model/PageMigrationSuccess.java index 4177d6f6..09f29156 100644 --- a/client/src/main/java/com/fastcomments/model/PageMigrationSuccess.java +++ b/client/src/main/java/com/fastcomments/model/PageMigrationSuccess.java @@ -174,6 +174,50 @@ public void setCommentsMigrated(@javax.annotation.Nonnull Integer commentsMigrat this.commentsMigrated = commentsMigrated; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PageMigrationSuccess instance itself + */ + public PageMigrationSuccess putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -189,12 +233,13 @@ public boolean equals(Object o) { Objects.equals(this.to, pageMigrationSuccess.to) && Objects.equals(this.type, pageMigrationSuccess.type) && Objects.equals(this.status, pageMigrationSuccess.status) && - Objects.equals(this.commentsMigrated, pageMigrationSuccess.commentsMigrated); + Objects.equals(this.commentsMigrated, pageMigrationSuccess.commentsMigrated)&& + Objects.equals(this.additionalProperties, pageMigrationSuccess.additionalProperties); } @Override public int hashCode() { - return Objects.hash(from, to, type, status, commentsMigrated); + return Objects.hash(from, to, type, status, commentsMigrated, additionalProperties); } @Override @@ -206,6 +251,7 @@ public String toString() { sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" commentsMigrated: ").append(toIndentedString(commentsMigrated)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -243,14 +289,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PageMigrationSuccess.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PageMigrationSuccess` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PageMigrationSuccess.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -285,6 +323,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PageMigrationSuccess value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -292,7 +352,28 @@ public void write(JsonWriter out, PageMigrationSuccess value) throws IOException public PageMigrationSuccess read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PageMigrationSuccess instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PageMigrationUndoCounts.java b/client/src/main/java/com/fastcomments/model/PageMigrationUndoCounts.java index db7b5b5e..b6c6c583 100644 --- a/client/src/main/java/com/fastcomments/model/PageMigrationUndoCounts.java +++ b/client/src/main/java/com/fastcomments/model/PageMigrationUndoCounts.java @@ -124,6 +124,50 @@ public void setNotRestorable(@javax.annotation.Nonnull Integer notRestorable) { this.notRestorable = notRestorable; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PageMigrationUndoCounts instance itself + */ + public PageMigrationUndoCounts putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -137,12 +181,13 @@ public boolean equals(Object o) { PageMigrationUndoCounts pageMigrationUndoCounts = (PageMigrationUndoCounts) o; return Objects.equals(this.restored, pageMigrationUndoCounts.restored) && Objects.equals(this.skipped, pageMigrationUndoCounts.skipped) && - Objects.equals(this.notRestorable, pageMigrationUndoCounts.notRestorable); + Objects.equals(this.notRestorable, pageMigrationUndoCounts.notRestorable)&& + Objects.equals(this.additionalProperties, pageMigrationUndoCounts.additionalProperties); } @Override public int hashCode() { - return Objects.hash(restored, skipped, notRestorable); + return Objects.hash(restored, skipped, notRestorable, additionalProperties); } @Override @@ -152,6 +197,7 @@ public String toString() { sb.append(" restored: ").append(toIndentedString(restored)).append("\n"); sb.append(" skipped: ").append(toIndentedString(skipped)).append("\n"); sb.append(" notRestorable: ").append(toIndentedString(notRestorable)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -189,14 +235,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PageMigrationUndoCounts.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PageMigrationUndoCounts` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PageMigrationUndoCounts.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -221,6 +259,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PageMigrationUndoCounts value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -228,7 +288,28 @@ public void write(JsonWriter out, PageMigrationUndoCounts value) throws IOExcept public PageMigrationUndoCounts read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PageMigrationUndoCounts instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PatchDomainConfigParams.java b/client/src/main/java/com/fastcomments/model/PatchDomainConfigParams.java index 1c078f1c..b9515859 100644 --- a/client/src/main/java/com/fastcomments/model/PatchDomainConfigParams.java +++ b/client/src/main/java/com/fastcomments/model/PatchDomainConfigParams.java @@ -230,6 +230,50 @@ public void setEmailHeaders(@javax.annotation.Nullable Map email this.emailHeaders = emailHeaders; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PatchDomainConfigParams instance itself + */ + public PatchDomainConfigParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -247,12 +291,13 @@ public boolean equals(Object o) { Objects.equals(this.logoSrc, patchDomainConfigParams.logoSrc) && Objects.equals(this.logoSrc100px, patchDomainConfigParams.logoSrc100px) && Objects.equals(this.footerUnsubscribeURL, patchDomainConfigParams.footerUnsubscribeURL) && - Objects.equals(this.emailHeaders, patchDomainConfigParams.emailHeaders); + Objects.equals(this.emailHeaders, patchDomainConfigParams.emailHeaders)&& + Objects.equals(this.additionalProperties, patchDomainConfigParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(domain, emailFromName, emailFromEmail, logoSrc, logoSrc100px, footerUnsubscribeURL, emailHeaders); + return Objects.hash(domain, emailFromName, emailFromEmail, logoSrc, logoSrc100px, footerUnsubscribeURL, emailHeaders, additionalProperties); } @Override @@ -266,6 +311,7 @@ public String toString() { sb.append(" logoSrc100px: ").append(toIndentedString(logoSrc100px)).append("\n"); sb.append(" footerUnsubscribeURL: ").append(toIndentedString(footerUnsubscribeURL)).append("\n"); sb.append(" emailHeaders: ").append(toIndentedString(emailHeaders)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -302,14 +348,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in PatchDomainConfigParams is not found in the empty JSON string", PatchDomainConfigParams.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PatchDomainConfigParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PatchDomainConfigParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("domain") != null && !jsonObj.get("domain").isJsonNull()) && !jsonObj.get("domain").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `domain` to be a primitive type in the JSON string but got `%s`", jsonObj.get("domain").toString())); @@ -346,6 +384,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PatchDomainConfigParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -353,7 +413,28 @@ public void write(JsonWriter out, PatchDomainConfigParams value) throws IOExcept public PatchDomainConfigParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PatchDomainConfigParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PendingCommentToSyncOutbound.java b/client/src/main/java/com/fastcomments/model/PendingCommentToSyncOutbound.java index d4ad8a98..73ae5ec8 100644 --- a/client/src/main/java/com/fastcomments/model/PendingCommentToSyncOutbound.java +++ b/client/src/main/java/com/fastcomments/model/PendingCommentToSyncOutbound.java @@ -366,6 +366,50 @@ public void setWebhookId(@javax.annotation.Nullable String webhookId) { this.webhookId = webhookId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PendingCommentToSyncOutbound instance itself + */ + public PendingCommentToSyncOutbound putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -389,12 +433,13 @@ public boolean equals(Object o) { Objects.equals(this.type, pendingCommentToSyncOutbound.type) && Objects.equals(this.domain, pendingCommentToSyncOutbound.domain) && Objects.equals(this.lastError, pendingCommentToSyncOutbound.lastError) && - Objects.equals(this.webhookId, pendingCommentToSyncOutbound.webhookId); + Objects.equals(this.webhookId, pendingCommentToSyncOutbound.webhookId)&& + Objects.equals(this.additionalProperties, pendingCommentToSyncOutbound.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, commentId, comment, externalId, createdAt, tenantId, attemptCount, nextAttemptAt, eventType, type, domain, lastError, webhookId); + return Objects.hash(id, commentId, comment, externalId, createdAt, tenantId, attemptCount, nextAttemptAt, eventType, type, domain, lastError, webhookId, additionalProperties); } @Override @@ -414,6 +459,7 @@ public String toString() { sb.append(" domain: ").append(toIndentedString(domain)).append("\n"); sb.append(" lastError: ").append(toIndentedString(lastError)).append("\n"); sb.append(" webhookId: ").append(toIndentedString(webhookId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -451,14 +497,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PendingCommentToSyncOutbound.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PendingCommentToSyncOutbound` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PendingCommentToSyncOutbound.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -505,6 +543,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PendingCommentToSyncOutbound value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -512,7 +572,28 @@ public void write(JsonWriter out, PendingCommentToSyncOutbound value) throws IOE public PendingCommentToSyncOutbound read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PendingCommentToSyncOutbound instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PollVoterEntry.java b/client/src/main/java/com/fastcomments/model/PollVoterEntry.java index 21194f92..a12de7ce 100644 --- a/client/src/main/java/com/fastcomments/model/PollVoterEntry.java +++ b/client/src/main/java/com/fastcomments/model/PollVoterEntry.java @@ -100,6 +100,50 @@ public void setOptionLabel(@javax.annotation.Nonnull String optionLabel) { this.optionLabel = optionLabel; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PollVoterEntry instance itself + */ + public PollVoterEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -112,12 +156,13 @@ public boolean equals(Object o) { } PollVoterEntry pollVoterEntry = (PollVoterEntry) o; return Objects.equals(this.name, pollVoterEntry.name) && - Objects.equals(this.optionLabel, pollVoterEntry.optionLabel); + Objects.equals(this.optionLabel, pollVoterEntry.optionLabel)&& + Objects.equals(this.additionalProperties, pollVoterEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, optionLabel); + return Objects.hash(name, optionLabel, additionalProperties); } @Override @@ -126,6 +171,7 @@ public String toString() { sb.append("class PollVoterEntry {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" optionLabel: ").append(toIndentedString(optionLabel)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -163,14 +209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PollVoterEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PollVoterEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PollVoterEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PollVoterEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, PollVoterEntry value) throws IOException { public PollVoterEntry read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PollVoterEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PreBanSummary.java b/client/src/main/java/com/fastcomments/model/PreBanSummary.java index c9957b81..26366f23 100644 --- a/client/src/main/java/com/fastcomments/model/PreBanSummary.java +++ b/client/src/main/java/com/fastcomments/model/PreBanSummary.java @@ -135,6 +135,50 @@ public void setCount(@javax.annotation.Nonnull Double count) { this.count = count; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PreBanSummary instance itself + */ + public PreBanSummary putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -148,12 +192,13 @@ public boolean equals(Object o) { PreBanSummary preBanSummary = (PreBanSummary) o; return Objects.equals(this.status, preBanSummary.status) && Objects.equals(this.usernames, preBanSummary.usernames) && - Objects.equals(this.count, preBanSummary.count); + Objects.equals(this.count, preBanSummary.count)&& + Objects.equals(this.additionalProperties, preBanSummary.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, usernames, count); + return Objects.hash(status, usernames, count, additionalProperties); } @Override @@ -163,6 +208,7 @@ public String toString() { sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" usernames: ").append(toIndentedString(usernames)).append("\n"); sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -200,14 +246,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PreBanSummary.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PreBanSummary` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PreBanSummary.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -240,6 +278,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PreBanSummary value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -247,7 +307,28 @@ public void write(JsonWriter out, PreBanSummary value) throws IOException { public PreBanSummary read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PreBanSummary instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PubSubCommentBase.java b/client/src/main/java/com/fastcomments/model/PubSubCommentBase.java index 8adb4411..b7a8e2f6 100644 --- a/client/src/main/java/com/fastcomments/model/PubSubCommentBase.java +++ b/client/src/main/java/com/fastcomments/model/PubSubCommentBase.java @@ -1065,6 +1065,50 @@ public void setGroupIds(@javax.annotation.Nullable List groupIds) { this.groupIds = groupIds; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PubSubCommentBase instance itself + */ + public PubSubCommentBase putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -1116,12 +1160,13 @@ public boolean equals(Object o) { Objects.equals(this.approved, pubSubCommentBase.approved) && Objects.equals(this.locale, pubSubCommentBase.locale) && Objects.equals(this.isBannedUser, pubSubCommentBase.isBannedUser) && - Objects.equals(this.groupIds, pubSubCommentBase.groupIds); + Objects.equals(this.groupIds, pubSubCommentBase.groupIds)&& + Objects.equals(this.additionalProperties, pubSubCommentBase.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, userId, urlId, commenterName, commenterLink, commentHTML, comment, parentId, votes, votesUp, votesDown, verified, avatarSrc, hasImages, hasLinks, isByAdmin, isByModerator, isPinned, isLocked, displayLabel, rating, badges, viewCount, isDeleted, isDeletedUser, isSpam, anonUserId, feedbackIds, poll, flagCount, domain, url, pageTitle, expireAt, reviewed, hasCode, approved, locale, isBannedUser, groupIds); + return Objects.hash(id, tenantId, userId, urlId, commenterName, commenterLink, commentHTML, comment, parentId, votes, votesUp, votesDown, verified, avatarSrc, hasImages, hasLinks, isByAdmin, isByModerator, isPinned, isLocked, displayLabel, rating, badges, viewCount, isDeleted, isDeletedUser, isSpam, anonUserId, feedbackIds, poll, flagCount, domain, url, pageTitle, expireAt, reviewed, hasCode, approved, locale, isBannedUser, groupIds, additionalProperties); } @Override @@ -1169,6 +1214,7 @@ public String toString() { sb.append(" locale: ").append(toIndentedString(locale)).append("\n"); sb.append(" isBannedUser: ").append(toIndentedString(isBannedUser)).append("\n"); sb.append(" groupIds: ").append(toIndentedString(groupIds)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -1206,14 +1252,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PubSubCommentBase.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PubSubCommentBase` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PubSubCommentBase.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -1312,6 +1350,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PubSubCommentBase value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -1319,7 +1379,28 @@ public void write(JsonWriter out, PubSubCommentBase value) throws IOException { public PubSubCommentBase read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PubSubCommentBase instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PubSubVote.java b/client/src/main/java/com/fastcomments/model/PubSubVote.java index 430a95a8..9a9494ac 100644 --- a/client/src/main/java/com/fastcomments/model/PubSubVote.java +++ b/client/src/main/java/com/fastcomments/model/PubSubVote.java @@ -268,6 +268,50 @@ public void setVerificationId(@javax.annotation.Nullable String verificationId) this.verificationId = verificationId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PubSubVote instance itself + */ + public PubSubVote putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -287,12 +331,13 @@ public boolean equals(Object o) { Objects.equals(this.userId, pubSubVote.userId) && Objects.equals(this.direction, pubSubVote.direction) && Objects.equals(this.createdAt, pubSubVote.createdAt) && - Objects.equals(this.verificationId, pubSubVote.verificationId); + Objects.equals(this.verificationId, pubSubVote.verificationId)&& + Objects.equals(this.additionalProperties, pubSubVote.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, urlId, urlIdRaw, commentId, userId, direction, createdAt, verificationId); + return Objects.hash(id, tenantId, urlId, urlIdRaw, commentId, userId, direction, createdAt, verificationId, additionalProperties); } @Override @@ -308,6 +353,7 @@ public String toString() { sb.append(" direction: ").append(toIndentedString(direction)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); sb.append(" verificationId: ").append(toIndentedString(verificationId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -345,14 +391,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PubSubVote.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PubSubVote` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PubSubVote.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -398,6 +436,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PubSubVote value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -405,7 +465,28 @@ public void write(JsonWriter out, PubSubVote value) throws IOException { public PubSubVote read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PubSubVote instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PublicBlockFromCommentParams.java b/client/src/main/java/com/fastcomments/model/PublicBlockFromCommentParams.java index d9e74043..b2d07f76 100644 --- a/client/src/main/java/com/fastcomments/model/PublicBlockFromCommentParams.java +++ b/client/src/main/java/com/fastcomments/model/PublicBlockFromCommentParams.java @@ -86,6 +86,50 @@ public void setCommentIds(@javax.annotation.Nullable List commentIds) { this.commentIds = commentIds; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PublicBlockFromCommentParams instance itself + */ + public PublicBlockFromCommentParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } PublicBlockFromCommentParams publicBlockFromCommentParams = (PublicBlockFromCommentParams) o; - return Objects.equals(this.commentIds, publicBlockFromCommentParams.commentIds); + return Objects.equals(this.commentIds, publicBlockFromCommentParams.commentIds)&& + Objects.equals(this.additionalProperties, publicBlockFromCommentParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(commentIds); + return Objects.hash(commentIds, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PublicBlockFromCommentParams {\n"); sb.append(" commentIds: ").append(toIndentedString(commentIds)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -147,14 +193,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PublicBlockFromCommentParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PublicBlockFromCommentParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PublicBlockFromCommentParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -185,6 +223,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PublicBlockFromCommentParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -192,7 +252,28 @@ public void write(JsonWriter out, PublicBlockFromCommentParams value) throws IOE public PublicBlockFromCommentParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PublicBlockFromCommentParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PublicCommentBase.java b/client/src/main/java/com/fastcomments/model/PublicCommentBase.java index 6aad3acb..4b122230 100644 --- a/client/src/main/java/com/fastcomments/model/PublicCommentBase.java +++ b/client/src/main/java/com/fastcomments/model/PublicCommentBase.java @@ -793,6 +793,50 @@ public void setApproved(@javax.annotation.Nullable Boolean approved) { this.approved = approved; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PublicCommentBase instance itself + */ + public PublicCommentBase putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -833,12 +877,13 @@ public boolean equals(Object o) { Objects.equals(this.poll, publicCommentBase.poll) && Objects.equals(this.requiresVerification, publicCommentBase.requiresVerification) && Objects.equals(this.editKey, publicCommentBase.editKey) && - Objects.equals(this.approved, publicCommentBase.approved); + Objects.equals(this.approved, publicCommentBase.approved)&& + Objects.equals(this.additionalProperties, publicCommentBase.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, userId, commenterName, commenterLink, commentHTML, parentId, date, votes, votesUp, votesDown, verified, avatarSrc, hasImages, isByAdmin, isByModerator, isPinned, isLocked, displayLabel, rating, badges, viewCount, isDeleted, isDeletedUser, isSpam, anonUserId, feedbackIds, poll, requiresVerification, editKey, approved); + return Objects.hash(id, userId, commenterName, commenterLink, commentHTML, parentId, date, votes, votesUp, votesDown, verified, avatarSrc, hasImages, isByAdmin, isByModerator, isPinned, isLocked, displayLabel, rating, badges, viewCount, isDeleted, isDeletedUser, isSpam, anonUserId, feedbackIds, poll, requiresVerification, editKey, approved, additionalProperties); } @Override @@ -875,6 +920,7 @@ public String toString() { sb.append(" requiresVerification: ").append(toIndentedString(requiresVerification)).append("\n"); sb.append(" editKey: ").append(toIndentedString(editKey)).append("\n"); sb.append(" approved: ").append(toIndentedString(approved)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -912,14 +958,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PublicCommentBase.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PublicCommentBase` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PublicCommentBase.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -996,6 +1034,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PublicCommentBase value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -1003,7 +1063,28 @@ public void write(JsonWriter out, PublicCommentBase value) throws IOException { public PublicCommentBase read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PublicCommentBase instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PublicPollVote.java b/client/src/main/java/com/fastcomments/model/PublicPollVote.java index a8a860af..10b9e091 100644 --- a/client/src/main/java/com/fastcomments/model/PublicPollVote.java +++ b/client/src/main/java/com/fastcomments/model/PublicPollVote.java @@ -245,6 +245,50 @@ public void setUpdatedAt(@javax.annotation.Nullable OffsetDateTime updatedAt) { this.updatedAt = updatedAt; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PublicPollVote instance itself + */ + public PublicPollVote putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -263,12 +307,13 @@ public boolean equals(Object o) { Objects.equals(this.voterId, publicPollVote.voterId) && Objects.equals(this.optionId, publicPollVote.optionId) && Objects.equals(this.createdAt, publicPollVote.createdAt) && - Objects.equals(this.updatedAt, publicPollVote.updatedAt); + Objects.equals(this.updatedAt, publicPollVote.updatedAt)&& + Objects.equals(this.additionalProperties, publicPollVote.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, commentId, urlId, voterId, optionId, createdAt, updatedAt); + return Objects.hash(id, tenantId, commentId, urlId, voterId, optionId, createdAt, updatedAt, additionalProperties); } @Override @@ -283,6 +328,7 @@ public String toString() { sb.append(" optionId: ").append(toIndentedString(optionId)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -320,14 +366,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PublicPollVote.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PublicPollVote` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PublicPollVote.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -370,6 +408,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PublicPollVote value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -377,7 +437,28 @@ public void write(JsonWriter out, PublicPollVote value) throws IOException { public PublicPollVote read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PublicPollVote instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PublicVote.java b/client/src/main/java/com/fastcomments/model/PublicVote.java index 7f96fa41..935b1c2c 100644 --- a/client/src/main/java/com/fastcomments/model/PublicVote.java +++ b/client/src/main/java/com/fastcomments/model/PublicVote.java @@ -197,6 +197,50 @@ public void setCreatedAt(@javax.annotation.Nonnull OffsetDateTime createdAt) { this.createdAt = createdAt; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PublicVote instance itself + */ + public PublicVote putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -213,12 +257,13 @@ public boolean equals(Object o) { Objects.equals(this.commentId, publicVote.commentId) && Objects.equals(this.userId, publicVote.userId) && Objects.equals(this.direction, publicVote.direction) && - Objects.equals(this.createdAt, publicVote.createdAt); + Objects.equals(this.createdAt, publicVote.createdAt)&& + Objects.equals(this.additionalProperties, publicVote.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, urlId, commentId, userId, direction, createdAt); + return Objects.hash(id, urlId, commentId, userId, direction, createdAt, additionalProperties); } @Override @@ -231,6 +276,7 @@ public String toString() { sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); sb.append(" direction: ").append(toIndentedString(direction)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -268,14 +314,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PublicVote.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PublicVote` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PublicVote.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -315,6 +353,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PublicVote value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -322,7 +382,28 @@ public void write(JsonWriter out, PublicVote value) throws IOException { public PublicVote read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PublicVote instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/PublicWebhook.java b/client/src/main/java/com/fastcomments/model/PublicWebhook.java index 180db19a..cfda4fb1 100644 --- a/client/src/main/java/com/fastcomments/model/PublicWebhook.java +++ b/client/src/main/java/com/fastcomments/model/PublicWebhook.java @@ -420,6 +420,50 @@ public void setDisabledReason(@javax.annotation.Nullable DisabledReasonEnum disa this.disabledReason = disabledReason; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the PublicWebhook instance itself + */ + public PublicWebhook putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -443,12 +487,13 @@ public boolean equals(Object o) { Objects.equals(this.lastFailureAt, publicWebhook.lastFailureAt) && Objects.equals(this.failingSince, publicWebhook.failingSince) && Objects.equals(this.disabledAt, publicWebhook.disabledAt) && - Objects.equals(this.disabledReason, publicWebhook.disabledReason); + Objects.equals(this.disabledReason, publicWebhook.disabledReason)&& + Objects.equals(this.additionalProperties, publicWebhook.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, url, event, domain, method, source, enabled, createdAt, lastSuccessAt, lastFailureAt, failingSince, disabledAt, disabledReason); + return Objects.hash(id, url, event, domain, method, source, enabled, createdAt, lastSuccessAt, lastFailureAt, failingSince, disabledAt, disabledReason, additionalProperties); } @Override @@ -468,6 +513,7 @@ public String toString() { sb.append(" failingSince: ").append(toIndentedString(failingSince)).append("\n"); sb.append(" disabledAt: ").append(toIndentedString(disabledAt)).append("\n"); sb.append(" disabledReason: ").append(toIndentedString(disabledReason)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -505,14 +551,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PublicWebhook.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PublicWebhook` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PublicWebhook.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -559,6 +597,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PublicWebhook value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -566,7 +626,28 @@ public void write(JsonWriter out, PublicWebhook value) throws IOException { public PublicWebhook read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PublicWebhook instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/QueryPredicate.java b/client/src/main/java/com/fastcomments/model/QueryPredicate.java index 2dc91a77..1af03df9 100644 --- a/client/src/main/java/com/fastcomments/model/QueryPredicate.java +++ b/client/src/main/java/com/fastcomments/model/QueryPredicate.java @@ -183,6 +183,50 @@ public void setOperator(@javax.annotation.Nonnull OperatorEnum operator) { this.operator = operator; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the QueryPredicate instance itself + */ + public QueryPredicate putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -196,12 +240,13 @@ public boolean equals(Object o) { QueryPredicate queryPredicate = (QueryPredicate) o; return Objects.equals(this.key, queryPredicate.key) && Objects.equals(this.value, queryPredicate.value) && - Objects.equals(this.operator, queryPredicate.operator); + Objects.equals(this.operator, queryPredicate.operator)&& + Objects.equals(this.additionalProperties, queryPredicate.additionalProperties); } @Override public int hashCode() { - return Objects.hash(key, value, operator); + return Objects.hash(key, value, operator, additionalProperties); } @Override @@ -211,6 +256,7 @@ public String toString() { sb.append(" key: ").append(toIndentedString(key)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); sb.append(" operator: ").append(toIndentedString(operator)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -248,14 +294,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!QueryPredicate.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `QueryPredicate` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : QueryPredicate.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -290,6 +328,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, QueryPredicate value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -297,7 +357,28 @@ public void write(JsonWriter out, QueryPredicate value) throws IOException { public QueryPredicate read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + QueryPredicate instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/QuestionCondition.java b/client/src/main/java/com/fastcomments/model/QuestionCondition.java index f7572f08..702e4263 100644 --- a/client/src/main/java/com/fastcomments/model/QuestionCondition.java +++ b/client/src/main/java/com/fastcomments/model/QuestionCondition.java @@ -101,6 +101,50 @@ public void setValue(@javax.annotation.Nonnull Double value) { this.value = value; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the QuestionCondition instance itself + */ + public QuestionCondition putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -113,12 +157,13 @@ public boolean equals(Object o) { } QuestionCondition questionCondition = (QuestionCondition) o; return Objects.equals(this.operator, questionCondition.operator) && - Objects.equals(this.value, questionCondition.value); + Objects.equals(this.value, questionCondition.value)&& + Objects.equals(this.additionalProperties, questionCondition.additionalProperties); } @Override public int hashCode() { - return Objects.hash(operator, value); + return Objects.hash(operator, value, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class QuestionCondition {\n"); sb.append(" operator: ").append(toIndentedString(operator)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -164,14 +210,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!QuestionCondition.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `QuestionCondition` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : QuestionCondition.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -198,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, QuestionCondition value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,7 +265,28 @@ public void write(JsonWriter out, QuestionCondition value) throws IOException { public QuestionCondition read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + QuestionCondition instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/QuestionConfig.java b/client/src/main/java/com/fastcomments/model/QuestionConfig.java index 9eea4f79..f916a488 100644 --- a/client/src/main/java/com/fastcomments/model/QuestionConfig.java +++ b/client/src/main/java/com/fastcomments/model/QuestionConfig.java @@ -658,6 +658,50 @@ public void setReportingOrder(@javax.annotation.Nonnull Double reportingOrder) { this.reportingOrder = reportingOrder; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the QuestionConfig instance itself + */ + public QuestionConfig putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -692,12 +736,13 @@ public boolean equals(Object o) { Objects.equals(this.subQuestionConditions, questionConfig.subQuestionConditions) && Objects.equals(this.commentBoxCondition, questionConfig.commentBoxCondition) && Objects.equals(this.commentBoxPrompt, questionConfig.commentBoxPrompt) && - Objects.equals(this.reportingOrder, questionConfig.reportingOrder); + Objects.equals(this.reportingOrder, questionConfig.reportingOrder)&& + Objects.equals(this.additionalProperties, questionConfig.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, name, question, summaryLabel, helpText, createdAt, createdBy, usedCount, lastUsed, type, numStars, min, max, defaultValue, labelNegative, labelPositive, customOptions, subQuestionIds, alwaysShowSubQuestions, subQuestionConditions, commentBoxCondition, commentBoxPrompt, reportingOrder); + return Objects.hash(id, tenantId, name, question, summaryLabel, helpText, createdAt, createdBy, usedCount, lastUsed, type, numStars, min, max, defaultValue, labelNegative, labelPositive, customOptions, subQuestionIds, alwaysShowSubQuestions, subQuestionConditions, commentBoxCondition, commentBoxPrompt, reportingOrder, additionalProperties); } @Override @@ -728,6 +773,7 @@ public String toString() { sb.append(" commentBoxCondition: ").append(toIndentedString(commentBoxCondition)).append("\n"); sb.append(" commentBoxPrompt: ").append(toIndentedString(commentBoxPrompt)).append("\n"); sb.append(" reportingOrder: ").append(toIndentedString(reportingOrder)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -765,14 +811,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!QuestionConfig.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `QuestionConfig` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : QuestionConfig.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -864,6 +902,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, QuestionConfig value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -871,7 +931,28 @@ public void write(JsonWriter out, QuestionConfig value) throws IOException { public QuestionConfig read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + QuestionConfig instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/QuestionDatum.java b/client/src/main/java/com/fastcomments/model/QuestionDatum.java index 0c5476ac..18236c04 100644 --- a/client/src/main/java/com/fastcomments/model/QuestionDatum.java +++ b/client/src/main/java/com/fastcomments/model/QuestionDatum.java @@ -110,6 +110,50 @@ public void setTotal(@javax.annotation.Nonnull Long total) { this.total = total; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the QuestionDatum instance itself + */ + public QuestionDatum putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -122,12 +166,13 @@ public boolean equals(Object o) { } QuestionDatum questionDatum = (QuestionDatum) o; return Objects.equals(this.v, questionDatum.v) && - Objects.equals(this.total, questionDatum.total); + Objects.equals(this.total, questionDatum.total)&& + Objects.equals(this.additionalProperties, questionDatum.additionalProperties); } @Override public int hashCode() { - return Objects.hash(v, total); + return Objects.hash(v, total, additionalProperties); } @Override @@ -136,6 +181,7 @@ public String toString() { sb.append("class QuestionDatum {\n"); sb.append(" v: ").append(toIndentedString(v)).append("\n"); sb.append(" total: ").append(toIndentedString(total)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -173,14 +219,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!QuestionDatum.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `QuestionDatum` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : QuestionDatum.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -205,6 +243,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, QuestionDatum value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -212,7 +272,28 @@ public void write(JsonWriter out, QuestionDatum value) throws IOException { public QuestionDatum read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + QuestionDatum instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/QuestionResult.java b/client/src/main/java/com/fastcomments/model/QuestionResult.java index 2aaabd24..78033e0e 100644 --- a/client/src/main/java/com/fastcomments/model/QuestionResult.java +++ b/client/src/main/java/com/fastcomments/model/QuestionResult.java @@ -360,6 +360,50 @@ public void setIpHash(@javax.annotation.Nonnull String ipHash) { this.ipHash = ipHash; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the QuestionResult instance itself + */ + public QuestionResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -382,12 +426,13 @@ public boolean equals(Object o) { Objects.equals(this.commentId, questionResult.commentId) && Objects.equals(this.questionId, questionResult.questionId) && Objects.equals(this.meta, questionResult.meta) && - Objects.equals(this.ipHash, questionResult.ipHash); + Objects.equals(this.ipHash, questionResult.ipHash)&& + Objects.equals(this.additionalProperties, questionResult.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, urlId, anonUserId, userId, createdAt, value, values, commentId, questionId, meta, ipHash); + return Objects.hash(id, tenantId, urlId, anonUserId, userId, createdAt, value, values, commentId, questionId, meta, ipHash, additionalProperties); } @Override @@ -406,6 +451,7 @@ public String toString() { sb.append(" questionId: ").append(toIndentedString(questionId)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); sb.append(" ipHash: ").append(toIndentedString(ipHash)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -443,14 +489,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!QuestionResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `QuestionResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : QuestionResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -517,6 +555,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, QuestionResult value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -524,7 +584,28 @@ public void write(JsonWriter out, QuestionResult value) throws IOException { public QuestionResult read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + QuestionResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/QuestionResultAggregationOverall.java b/client/src/main/java/com/fastcomments/model/QuestionResultAggregationOverall.java index 6a6944ad..bb1c2d59 100644 --- a/client/src/main/java/com/fastcomments/model/QuestionResultAggregationOverall.java +++ b/client/src/main/java/com/fastcomments/model/QuestionResultAggregationOverall.java @@ -224,6 +224,50 @@ public void setCreatedAt(@javax.annotation.Nonnull OffsetDateTime createdAt) { this.createdAt = createdAt; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the QuestionResultAggregationOverall instance itself + */ + public QuestionResultAggregationOverall putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -240,12 +284,13 @@ public boolean equals(Object o) { Objects.equals(this.countsByValue, questionResultAggregationOverall.countsByValue) && Objects.equals(this.total, questionResultAggregationOverall.total) && Objects.equals(this.average, questionResultAggregationOverall.average) && - Objects.equals(this.createdAt, questionResultAggregationOverall.createdAt); + Objects.equals(this.createdAt, questionResultAggregationOverall.createdAt)&& + Objects.equals(this.additionalProperties, questionResultAggregationOverall.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataByDateBucket, dataByUrlId, countsByValue, total, average, createdAt); + return Objects.hash(dataByDateBucket, dataByUrlId, countsByValue, total, average, createdAt, additionalProperties); } @Override @@ -258,6 +303,7 @@ public String toString() { sb.append(" total: ").append(toIndentedString(total)).append("\n"); sb.append(" average: ").append(toIndentedString(average)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -295,14 +341,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!QuestionResultAggregationOverall.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `QuestionResultAggregationOverall` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : QuestionResultAggregationOverall.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -327,6 +365,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, QuestionResultAggregationOverall value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -334,7 +394,28 @@ public void write(JsonWriter out, QuestionResultAggregationOverall value) throws public QuestionResultAggregationOverall read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + QuestionResultAggregationOverall instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ReactBodyParams.java b/client/src/main/java/com/fastcomments/model/ReactBodyParams.java index 4317923c..2e3a88d4 100644 --- a/client/src/main/java/com/fastcomments/model/ReactBodyParams.java +++ b/client/src/main/java/com/fastcomments/model/ReactBodyParams.java @@ -76,6 +76,50 @@ public void setReactType(@javax.annotation.Nullable String reactType) { this.reactType = reactType; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ReactBodyParams instance itself + */ + public ReactBodyParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -87,12 +131,13 @@ public boolean equals(Object o) { return false; } ReactBodyParams reactBodyParams = (ReactBodyParams) o; - return Objects.equals(this.reactType, reactBodyParams.reactType); + return Objects.equals(this.reactType, reactBodyParams.reactType)&& + Objects.equals(this.additionalProperties, reactBodyParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(reactType); + return Objects.hash(reactType, additionalProperties); } @Override @@ -100,6 +145,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ReactBodyParams {\n"); sb.append(" reactType: ").append(toIndentedString(reactType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -136,14 +182,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in ReactBodyParams is not found in the empty JSON string", ReactBodyParams.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ReactBodyParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ReactBodyParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("reactType") != null && !jsonObj.get("reactType").isJsonNull()) && !jsonObj.get("reactType").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `reactType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reactType").toString())); @@ -165,6 +203,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ReactBodyParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -172,7 +232,28 @@ public void write(JsonWriter out, ReactBodyParams value) throws IOException { public ReactBodyParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ReactBodyParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ReactFeedPostResponse.java b/client/src/main/java/com/fastcomments/model/ReactFeedPostResponse.java index 78e5fc5b..4f299b3c 100644 --- a/client/src/main/java/com/fastcomments/model/ReactFeedPostResponse.java +++ b/client/src/main/java/com/fastcomments/model/ReactFeedPostResponse.java @@ -125,6 +125,50 @@ public void setIsUndo(@javax.annotation.Nonnull Boolean isUndo) { this.isUndo = isUndo; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ReactFeedPostResponse instance itself + */ + public ReactFeedPostResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -138,12 +182,13 @@ public boolean equals(Object o) { ReactFeedPostResponse reactFeedPostResponse = (ReactFeedPostResponse) o; return Objects.equals(this.status, reactFeedPostResponse.status) && Objects.equals(this.reactType, reactFeedPostResponse.reactType) && - Objects.equals(this.isUndo, reactFeedPostResponse.isUndo); + Objects.equals(this.isUndo, reactFeedPostResponse.isUndo)&& + Objects.equals(this.additionalProperties, reactFeedPostResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, reactType, isUndo); + return Objects.hash(status, reactType, isUndo, additionalProperties); } @Override @@ -153,6 +198,7 @@ public String toString() { sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" reactType: ").append(toIndentedString(reactType)).append("\n"); sb.append(" isUndo: ").append(toIndentedString(isUndo)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -190,14 +236,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ReactFeedPostResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ReactFeedPostResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ReactFeedPostResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -227,6 +265,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ReactFeedPostResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -234,7 +294,28 @@ public void write(JsonWriter out, ReactFeedPostResponse value) throws IOExceptio public ReactFeedPostResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ReactFeedPostResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/RemoveCommentActionResponse.java b/client/src/main/java/com/fastcomments/model/RemoveCommentActionResponse.java index 5604fe96..ae25d542 100644 --- a/client/src/main/java/com/fastcomments/model/RemoveCommentActionResponse.java +++ b/client/src/main/java/com/fastcomments/model/RemoveCommentActionResponse.java @@ -100,6 +100,50 @@ public void setAction(@javax.annotation.Nonnull String action) { this.action = action; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RemoveCommentActionResponse instance itself + */ + public RemoveCommentActionResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -112,12 +156,13 @@ public boolean equals(Object o) { } RemoveCommentActionResponse removeCommentActionResponse = (RemoveCommentActionResponse) o; return Objects.equals(this.status, removeCommentActionResponse.status) && - Objects.equals(this.action, removeCommentActionResponse.action); + Objects.equals(this.action, removeCommentActionResponse.action)&& + Objects.equals(this.additionalProperties, removeCommentActionResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, action); + return Objects.hash(status, action, additionalProperties); } @Override @@ -126,6 +171,7 @@ public String toString() { sb.append("class RemoveCommentActionResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" action: ").append(toIndentedString(action)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -163,14 +209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RemoveCommentActionResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RemoveCommentActionResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RemoveCommentActionResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RemoveCommentActionResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, RemoveCommentActionResponse value) throws IOEx public RemoveCommentActionResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RemoveCommentActionResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/RenderEmailTemplateBody.java b/client/src/main/java/com/fastcomments/model/RenderEmailTemplateBody.java index 6a8ea019..bf3a3921 100644 --- a/client/src/main/java/com/fastcomments/model/RenderEmailTemplateBody.java +++ b/client/src/main/java/com/fastcomments/model/RenderEmailTemplateBody.java @@ -166,6 +166,50 @@ public void setTranslationOverridesByLocale(@javax.annotation.Nullable Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RenderEmailTemplateBody instance itself + */ + public RenderEmailTemplateBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -180,12 +224,13 @@ public boolean equals(Object o) { return Objects.equals(this.emailTemplateId, renderEmailTemplateBody.emailTemplateId) && Objects.equals(this.ejs, renderEmailTemplateBody.ejs) && Objects.equals(this.testData, renderEmailTemplateBody.testData) && - Objects.equals(this.translationOverridesByLocale, renderEmailTemplateBody.translationOverridesByLocale); + Objects.equals(this.translationOverridesByLocale, renderEmailTemplateBody.translationOverridesByLocale)&& + Objects.equals(this.additionalProperties, renderEmailTemplateBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(emailTemplateId, ejs, testData, translationOverridesByLocale); + return Objects.hash(emailTemplateId, ejs, testData, translationOverridesByLocale, additionalProperties); } @Override @@ -196,6 +241,7 @@ public String toString() { sb.append(" ejs: ").append(toIndentedString(ejs)).append("\n"); sb.append(" testData: ").append(toIndentedString(testData)).append("\n"); sb.append(" translationOverridesByLocale: ").append(toIndentedString(translationOverridesByLocale)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -233,14 +279,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RenderEmailTemplateBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RenderEmailTemplateBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RenderEmailTemplateBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -271,6 +309,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RenderEmailTemplateBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -278,7 +338,28 @@ public void write(JsonWriter out, RenderEmailTemplateBody value) throws IOExcept public RenderEmailTemplateBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RenderEmailTemplateBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/RenderEmailTemplateResponse.java b/client/src/main/java/com/fastcomments/model/RenderEmailTemplateResponse.java index 85e40fe0..94fa57eb 100644 --- a/client/src/main/java/com/fastcomments/model/RenderEmailTemplateResponse.java +++ b/client/src/main/java/com/fastcomments/model/RenderEmailTemplateResponse.java @@ -101,6 +101,50 @@ public void setHtml(@javax.annotation.Nonnull String html) { this.html = html; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RenderEmailTemplateResponse instance itself + */ + public RenderEmailTemplateResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -113,12 +157,13 @@ public boolean equals(Object o) { } RenderEmailTemplateResponse renderEmailTemplateResponse = (RenderEmailTemplateResponse) o; return Objects.equals(this.status, renderEmailTemplateResponse.status) && - Objects.equals(this.html, renderEmailTemplateResponse.html); + Objects.equals(this.html, renderEmailTemplateResponse.html)&& + Objects.equals(this.additionalProperties, renderEmailTemplateResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, html); + return Objects.hash(status, html, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class RenderEmailTemplateResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" html: ").append(toIndentedString(html)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -164,14 +210,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RenderEmailTemplateResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RenderEmailTemplateResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RenderEmailTemplateResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RenderEmailTemplateResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, RenderEmailTemplateResponse value) throws IOEx public RenderEmailTemplateResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RenderEmailTemplateResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ReplaceTenantPackageBody.java b/client/src/main/java/com/fastcomments/model/ReplaceTenantPackageBody.java index 73391673..260ab506 100644 --- a/client/src/main/java/com/fastcomments/model/ReplaceTenantPackageBody.java +++ b/client/src/main/java/com/fastcomments/model/ReplaceTenantPackageBody.java @@ -806,6 +806,50 @@ public void setFlexMinimumCostCents(@javax.annotation.Nullable Double flexMinimu this.flexMinimumCostCents = flexMinimumCostCents; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ReplaceTenantPackageBody instance itself + */ + public ReplaceTenantPackageBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -847,12 +891,13 @@ public boolean equals(Object o) { Objects.equals(this.flexAdminUnit, replaceTenantPackageBody.flexAdminUnit) && Objects.equals(this.flexDomainCostCents, replaceTenantPackageBody.flexDomainCostCents) && Objects.equals(this.flexDomainUnit, replaceTenantPackageBody.flexDomainUnit) && - Objects.equals(this.flexMinimumCostCents, replaceTenantPackageBody.flexMinimumCostCents); + Objects.equals(this.flexMinimumCostCents, replaceTenantPackageBody.flexMinimumCostCents)&& + Objects.equals(this.additionalProperties, replaceTenantPackageBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, monthlyCostUSD, yearlyCostUSD, maxMonthlyPageLoads, maxMonthlyAPICredits, maxMonthlyComments, maxConcurrentUsers, maxTenantUsers, maxSSOUsers, maxModerators, maxDomains, maxCustomCollectionSize, hasDebranding, forWhoText, featureTaglines, hasFlexPricing, flexPageLoadCostCents, flexPageLoadUnit, flexCommentCostCents, flexCommentUnit, flexSSOUserCostCents, flexSSOUserUnit, flexAPICreditCostCents, flexAPICreditUnit, flexModeratorCostCents, flexModeratorUnit, flexAdminCostCents, flexAdminUnit, flexDomainCostCents, flexDomainUnit, flexMinimumCostCents); + return Objects.hash(name, monthlyCostUSD, yearlyCostUSD, maxMonthlyPageLoads, maxMonthlyAPICredits, maxMonthlyComments, maxConcurrentUsers, maxTenantUsers, maxSSOUsers, maxModerators, maxDomains, maxCustomCollectionSize, hasDebranding, forWhoText, featureTaglines, hasFlexPricing, flexPageLoadCostCents, flexPageLoadUnit, flexCommentCostCents, flexCommentUnit, flexSSOUserCostCents, flexSSOUserUnit, flexAPICreditCostCents, flexAPICreditUnit, flexModeratorCostCents, flexModeratorUnit, flexAdminCostCents, flexAdminUnit, flexDomainCostCents, flexDomainUnit, flexMinimumCostCents, additionalProperties); } @Override @@ -890,6 +935,7 @@ public String toString() { sb.append(" flexDomainCostCents: ").append(toIndentedString(flexDomainCostCents)).append("\n"); sb.append(" flexDomainUnit: ").append(toIndentedString(flexDomainUnit)).append("\n"); sb.append(" flexMinimumCostCents: ").append(toIndentedString(flexMinimumCostCents)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -927,14 +973,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ReplaceTenantPackageBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ReplaceTenantPackageBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ReplaceTenantPackageBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -971,6 +1009,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ReplaceTenantPackageBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -978,7 +1038,28 @@ public void write(JsonWriter out, ReplaceTenantPackageBody value) throws IOExcep public ReplaceTenantPackageBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ReplaceTenantPackageBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ReplaceTenantUserBody.java b/client/src/main/java/com/fastcomments/model/ReplaceTenantUserBody.java index 3f7d3c64..b293bb87 100644 --- a/client/src/main/java/com/fastcomments/model/ReplaceTenantUserBody.java +++ b/client/src/main/java/com/fastcomments/model/ReplaceTenantUserBody.java @@ -734,6 +734,50 @@ public void setKarma(@javax.annotation.Nullable Double karma) { this.karma = karma; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ReplaceTenantUserBody instance itself + */ + public ReplaceTenantUserBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -772,12 +816,13 @@ public boolean equals(Object o) { Objects.equals(this.createdFromUrlId, replaceTenantUserBody.createdFromUrlId) && Objects.equals(this.createdFromTenantId, replaceTenantUserBody.createdFromTenantId) && Objects.equals(this.lastLoginDate, replaceTenantUserBody.lastLoginDate) && - Objects.equals(this.karma, replaceTenantUserBody.karma); + Objects.equals(this.karma, replaceTenantUserBody.karma)&& + Objects.equals(this.additionalProperties, replaceTenantUserBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(username, email, displayName, websiteUrl, signUpDate, locale, verified, loginCount, optedInNotifications, optedInTenantNotifications, hideAccountCode, avatarSrc, isHelpRequestAdmin, isAccountOwner, isAdminAdmin, isBillingAdmin, isAnalyticsAdmin, isCustomizationAdmin, isManageDataAdmin, isCommentModeratorAdmin, isAPIAdmin, moderatorIds, digestEmailFrequency, displayLabel, createdFromUrlId, createdFromTenantId, lastLoginDate, karma); + return Objects.hash(username, email, displayName, websiteUrl, signUpDate, locale, verified, loginCount, optedInNotifications, optedInTenantNotifications, hideAccountCode, avatarSrc, isHelpRequestAdmin, isAccountOwner, isAdminAdmin, isBillingAdmin, isAnalyticsAdmin, isCustomizationAdmin, isManageDataAdmin, isCommentModeratorAdmin, isAPIAdmin, moderatorIds, digestEmailFrequency, displayLabel, createdFromUrlId, createdFromTenantId, lastLoginDate, karma, additionalProperties); } @Override @@ -812,6 +857,7 @@ public String toString() { sb.append(" createdFromTenantId: ").append(toIndentedString(createdFromTenantId)).append("\n"); sb.append(" lastLoginDate: ").append(toIndentedString(lastLoginDate)).append("\n"); sb.append(" karma: ").append(toIndentedString(karma)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -849,14 +895,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ReplaceTenantUserBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ReplaceTenantUserBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ReplaceTenantUserBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -912,6 +950,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ReplaceTenantUserBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -919,7 +979,28 @@ public void write(JsonWriter out, ReplaceTenantUserBody value) throws IOExceptio public ReplaceTenantUserBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ReplaceTenantUserBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/ResetUserNotificationsResponse.java b/client/src/main/java/com/fastcomments/model/ResetUserNotificationsResponse.java index ef9651b1..12f8c123 100644 --- a/client/src/main/java/com/fastcomments/model/ResetUserNotificationsResponse.java +++ b/client/src/main/java/com/fastcomments/model/ResetUserNotificationsResponse.java @@ -151,6 +151,50 @@ public void setCode(@javax.annotation.Nullable CodeEnum code) { this.code = code; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ResetUserNotificationsResponse instance itself + */ + public ResetUserNotificationsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -163,12 +207,13 @@ public boolean equals(Object o) { } ResetUserNotificationsResponse resetUserNotificationsResponse = (ResetUserNotificationsResponse) o; return Objects.equals(this.status, resetUserNotificationsResponse.status) && - Objects.equals(this.code, resetUserNotificationsResponse.code); + Objects.equals(this.code, resetUserNotificationsResponse.code)&& + Objects.equals(this.additionalProperties, resetUserNotificationsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, code); + return Objects.hash(status, code, additionalProperties); } @Override @@ -177,6 +222,7 @@ public String toString() { sb.append("class ResetUserNotificationsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -214,14 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ResetUserNotificationsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ResetUserNotificationsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ResetUserNotificationsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -255,6 +293,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ResetUserNotificationsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -262,7 +322,28 @@ public void write(JsonWriter out, ResetUserNotificationsResponse value) throws I public ResetUserNotificationsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ResetUserNotificationsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/SaveCommentResponseOptimized.java b/client/src/main/java/com/fastcomments/model/SaveCommentResponseOptimized.java index ee5e2942..aed1b073 100644 --- a/client/src/main/java/com/fastcomments/model/SaveCommentResponseOptimized.java +++ b/client/src/main/java/com/fastcomments/model/SaveCommentResponseOptimized.java @@ -161,6 +161,50 @@ public void setModuleData(@javax.annotation.Nullable Map moduleD this.moduleData = moduleData; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SaveCommentResponseOptimized instance itself + */ + public SaveCommentResponseOptimized putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -175,12 +219,13 @@ public boolean equals(Object o) { return Objects.equals(this.status, saveCommentResponseOptimized.status) && Objects.equals(this.comment, saveCommentResponseOptimized.comment) && Objects.equals(this.user, saveCommentResponseOptimized.user) && - Objects.equals(this.moduleData, saveCommentResponseOptimized.moduleData); + Objects.equals(this.moduleData, saveCommentResponseOptimized.moduleData)&& + Objects.equals(this.additionalProperties, saveCommentResponseOptimized.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, comment, user, moduleData); + return Objects.hash(status, comment, user, moduleData, additionalProperties); } @Override @@ -191,6 +236,7 @@ public String toString() { sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); sb.append(" user: ").append(toIndentedString(user)).append("\n"); sb.append(" moduleData: ").append(toIndentedString(moduleData)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -228,14 +274,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SaveCommentResponseOptimized.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SaveCommentResponseOptimized` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SaveCommentResponseOptimized.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -268,6 +306,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SaveCommentResponseOptimized value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -275,7 +335,28 @@ public void write(JsonWriter out, SaveCommentResponseOptimized value) throws IOE public SaveCommentResponseOptimized read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SaveCommentResponseOptimized instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/SavePollResponse.java b/client/src/main/java/com/fastcomments/model/SavePollResponse.java index 0717fe5f..8b815fef 100644 --- a/client/src/main/java/com/fastcomments/model/SavePollResponse.java +++ b/client/src/main/java/com/fastcomments/model/SavePollResponse.java @@ -102,6 +102,50 @@ public void setPoll(@javax.annotation.Nonnull CommentPoll poll) { this.poll = poll; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SavePollResponse instance itself + */ + public SavePollResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } SavePollResponse savePollResponse = (SavePollResponse) o; return Objects.equals(this.status, savePollResponse.status) && - Objects.equals(this.poll, savePollResponse.poll); + Objects.equals(this.poll, savePollResponse.poll)&& + Objects.equals(this.additionalProperties, savePollResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, poll); + return Objects.hash(status, poll, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class SavePollResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" poll: ").append(toIndentedString(poll)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SavePollResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SavePollResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SavePollResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SavePollResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, SavePollResponse value) throws IOException { public SavePollResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SavePollResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/SetCommentTextParams.java b/client/src/main/java/com/fastcomments/model/SetCommentTextParams.java index 32593a8a..a93fe572 100644 --- a/client/src/main/java/com/fastcomments/model/SetCommentTextParams.java +++ b/client/src/main/java/com/fastcomments/model/SetCommentTextParams.java @@ -76,6 +76,50 @@ public void setComment(@javax.annotation.Nonnull String comment) { this.comment = comment; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SetCommentTextParams instance itself + */ + public SetCommentTextParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -87,12 +131,13 @@ public boolean equals(Object o) { return false; } SetCommentTextParams setCommentTextParams = (SetCommentTextParams) o; - return Objects.equals(this.comment, setCommentTextParams.comment); + return Objects.equals(this.comment, setCommentTextParams.comment)&& + Objects.equals(this.additionalProperties, setCommentTextParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(comment); + return Objects.hash(comment, additionalProperties); } @Override @@ -100,6 +145,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class SetCommentTextParams {\n"); sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -137,14 +183,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SetCommentTextParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SetCommentTextParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SetCommentTextParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -172,6 +210,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SetCommentTextParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -179,7 +239,28 @@ public void write(JsonWriter out, SetCommentTextParams value) throws IOException public SetCommentTextParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SetCommentTextParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/SetCommentTextResult.java b/client/src/main/java/com/fastcomments/model/SetCommentTextResult.java index 7cd0f802..44717934 100644 --- a/client/src/main/java/com/fastcomments/model/SetCommentTextResult.java +++ b/client/src/main/java/com/fastcomments/model/SetCommentTextResult.java @@ -100,6 +100,50 @@ public void setCommentHTML(@javax.annotation.Nonnull String commentHTML) { this.commentHTML = commentHTML; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SetCommentTextResult instance itself + */ + public SetCommentTextResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -112,12 +156,13 @@ public boolean equals(Object o) { } SetCommentTextResult setCommentTextResult = (SetCommentTextResult) o; return Objects.equals(this.approved, setCommentTextResult.approved) && - Objects.equals(this.commentHTML, setCommentTextResult.commentHTML); + Objects.equals(this.commentHTML, setCommentTextResult.commentHTML)&& + Objects.equals(this.additionalProperties, setCommentTextResult.additionalProperties); } @Override public int hashCode() { - return Objects.hash(approved, commentHTML); + return Objects.hash(approved, commentHTML, additionalProperties); } @Override @@ -126,6 +171,7 @@ public String toString() { sb.append("class SetCommentTextResult {\n"); sb.append(" approved: ").append(toIndentedString(approved)).append("\n"); sb.append(" commentHTML: ").append(toIndentedString(commentHTML)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -163,14 +209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SetCommentTextResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SetCommentTextResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SetCommentTextResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -198,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SetCommentTextResult value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,7 +265,28 @@ public void write(JsonWriter out, SetCommentTextResult value) throws IOException public SetCommentTextResult read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SetCommentTextResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/SpamRule.java b/client/src/main/java/com/fastcomments/model/SpamRule.java index 92281e61..f24ffd08 100644 --- a/client/src/main/java/com/fastcomments/model/SpamRule.java +++ b/client/src/main/java/com/fastcomments/model/SpamRule.java @@ -164,6 +164,50 @@ public void setCommentContains(@javax.annotation.Nullable String commentContains this.commentContains = commentContains; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SpamRule instance itself + */ + public SpamRule putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -176,12 +220,13 @@ public boolean equals(Object o) { } SpamRule spamRule = (SpamRule) o; return Objects.equals(this.actions, spamRule.actions) && - Objects.equals(this.commentContains, spamRule.commentContains); + Objects.equals(this.commentContains, spamRule.commentContains)&& + Objects.equals(this.additionalProperties, spamRule.additionalProperties); } @Override public int hashCode() { - return Objects.hash(actions, commentContains); + return Objects.hash(actions, commentContains, additionalProperties); } @Override @@ -190,6 +235,7 @@ public String toString() { sb.append("class SpamRule {\n"); sb.append(" actions: ").append(toIndentedString(actions)).append("\n"); sb.append(" commentContains: ").append(toIndentedString(commentContains)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -227,14 +273,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SpamRule.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SpamRule` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SpamRule.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -268,6 +306,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SpamRule value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -275,7 +335,28 @@ public void write(JsonWriter out, SpamRule value) throws IOException { public SpamRule read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SpamRule instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/SubQuestionCondition.java b/client/src/main/java/com/fastcomments/model/SubQuestionCondition.java index 4dd0265f..05f6d897 100644 --- a/client/src/main/java/com/fastcomments/model/SubQuestionCondition.java +++ b/client/src/main/java/com/fastcomments/model/SubQuestionCondition.java @@ -125,6 +125,50 @@ public void setSubQuestionId(@javax.annotation.Nonnull String subQuestionId) { this.subQuestionId = subQuestionId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SubQuestionCondition instance itself + */ + public SubQuestionCondition putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -138,12 +182,13 @@ public boolean equals(Object o) { SubQuestionCondition subQuestionCondition = (SubQuestionCondition) o; return Objects.equals(this.operator, subQuestionCondition.operator) && Objects.equals(this.value, subQuestionCondition.value) && - Objects.equals(this.subQuestionId, subQuestionCondition.subQuestionId); + Objects.equals(this.subQuestionId, subQuestionCondition.subQuestionId)&& + Objects.equals(this.additionalProperties, subQuestionCondition.additionalProperties); } @Override public int hashCode() { - return Objects.hash(operator, value, subQuestionId); + return Objects.hash(operator, value, subQuestionId, additionalProperties); } @Override @@ -153,6 +198,7 @@ public String toString() { sb.append(" operator: ").append(toIndentedString(operator)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); sb.append(" subQuestionId: ").append(toIndentedString(subQuestionId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -190,14 +236,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SubQuestionCondition.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SubQuestionCondition` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SubQuestionCondition.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -227,6 +265,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SubQuestionCondition value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -234,7 +294,28 @@ public void write(JsonWriter out, SubQuestionCondition value) throws IOException public SubQuestionCondition read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SubQuestionCondition instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/TOSConfig.java b/client/src/main/java/com/fastcomments/model/TOSConfig.java index 096704b3..4490f13f 100644 --- a/client/src/main/java/com/fastcomments/model/TOSConfig.java +++ b/client/src/main/java/com/fastcomments/model/TOSConfig.java @@ -135,6 +135,50 @@ public void setLastUpdated(@javax.annotation.Nullable OffsetDateTime lastUpdated this.lastUpdated = lastUpdated; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TOSConfig instance itself + */ + public TOSConfig putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -148,12 +192,13 @@ public boolean equals(Object o) { TOSConfig toSConfig = (TOSConfig) o; return Objects.equals(this.enabled, toSConfig.enabled) && Objects.equals(this.textByLocale, toSConfig.textByLocale) && - Objects.equals(this.lastUpdated, toSConfig.lastUpdated); + Objects.equals(this.lastUpdated, toSConfig.lastUpdated)&& + Objects.equals(this.additionalProperties, toSConfig.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled, textByLocale, lastUpdated); + return Objects.hash(enabled, textByLocale, lastUpdated, additionalProperties); } @Override @@ -163,6 +208,7 @@ public String toString() { sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); sb.append(" textByLocale: ").append(toIndentedString(textByLocale)).append("\n"); sb.append(" lastUpdated: ").append(toIndentedString(lastUpdated)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -199,14 +245,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in TOSConfig is not found in the empty JSON string", TOSConfig.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TOSConfig.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TOSConfig` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -225,6 +263,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TOSConfig value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -232,7 +292,28 @@ public void write(JsonWriter out, TOSConfig value) throws IOException { public TOSConfig read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TOSConfig instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/TenantBadge.java b/client/src/main/java/com/fastcomments/model/TenantBadge.java index aa938275..3694b7f7 100644 --- a/client/src/main/java/com/fastcomments/model/TenantBadge.java +++ b/client/src/main/java/com/fastcomments/model/TenantBadge.java @@ -557,6 +557,50 @@ public void setReplacesBadgeId(@javax.annotation.Nullable String replacesBadgeId this.replacesBadgeId = replacesBadgeId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TenantBadge instance itself + */ + public TenantBadge putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -588,12 +632,13 @@ public boolean equals(Object o) { Objects.equals(this.veteranUserThresholdMillis, tenantBadge.veteranUserThresholdMillis) && Objects.equals(this.isAwaitingReprocess, tenantBadge.isAwaitingReprocess) && Objects.equals(this.isAwaitingDeletion, tenantBadge.isAwaitingDeletion) && - Objects.equals(this.replacesBadgeId, tenantBadge.replacesBadgeId); + Objects.equals(this.replacesBadgeId, tenantBadge.replacesBadgeId)&& + Objects.equals(this.additionalProperties, tenantBadge.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, createdByUserId, createdAt, enabled, urlId, type, threshold, uses, name, description, displayLabel, displaySrc, backgroundColor, borderColor, textColor, cssClass, veteranUserThresholdMillis, isAwaitingReprocess, isAwaitingDeletion, replacesBadgeId); + return Objects.hash(id, tenantId, createdByUserId, createdAt, enabled, urlId, type, threshold, uses, name, description, displayLabel, displaySrc, backgroundColor, borderColor, textColor, cssClass, veteranUserThresholdMillis, isAwaitingReprocess, isAwaitingDeletion, replacesBadgeId, additionalProperties); } @Override @@ -621,6 +666,7 @@ public String toString() { sb.append(" isAwaitingReprocess: ").append(toIndentedString(isAwaitingReprocess)).append("\n"); sb.append(" isAwaitingDeletion: ").append(toIndentedString(isAwaitingDeletion)).append("\n"); sb.append(" replacesBadgeId: ").append(toIndentedString(replacesBadgeId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -658,14 +704,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TenantBadge.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TenantBadge` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TenantBadge.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -729,6 +767,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TenantBadge value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -736,7 +796,28 @@ public void write(JsonWriter out, TenantBadge value) throws IOException { public TenantBadge read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TenantBadge instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/TenantHashTag.java b/client/src/main/java/com/fastcomments/model/TenantHashTag.java index 09a461ab..0ccca55c 100644 --- a/client/src/main/java/com/fastcomments/model/TenantHashTag.java +++ b/client/src/main/java/com/fastcomments/model/TenantHashTag.java @@ -173,6 +173,50 @@ public void setUrl(@javax.annotation.Nullable String url) { this.url = url; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TenantHashTag instance itself + */ + public TenantHashTag putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -188,12 +232,13 @@ public boolean equals(Object o) { Objects.equals(this.createdAt, tenantHashTag.createdAt) && Objects.equals(this.tenantId, tenantHashTag.tenantId) && Objects.equals(this.tag, tenantHashTag.tag) && - Objects.equals(this.url, tenantHashTag.url); + Objects.equals(this.url, tenantHashTag.url)&& + Objects.equals(this.additionalProperties, tenantHashTag.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, createdAt, tenantId, tag, url); + return Objects.hash(id, createdAt, tenantId, tag, url, additionalProperties); } @Override @@ -205,6 +250,7 @@ public String toString() { sb.append(" tenantId: ").append(toIndentedString(tenantId)).append("\n"); sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -242,14 +288,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TenantHashTag.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TenantHashTag` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TenantHashTag.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -286,6 +324,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TenantHashTag value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -293,7 +353,28 @@ public void write(JsonWriter out, TenantHashTag value) throws IOException { public TenantHashTag read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TenantHashTag instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/TenantPackage.java b/client/src/main/java/com/fastcomments/model/TenantPackage.java index 293404be..106b63e1 100644 --- a/client/src/main/java/com/fastcomments/model/TenantPackage.java +++ b/client/src/main/java/com/fastcomments/model/TenantPackage.java @@ -88,6 +88,21 @@ public class TenantPackage { @javax.annotation.Nullable private Double yearlyCostUSD; + public static final String SERIALIZED_NAME_PRICING_CURRENCY = "pricingCurrency"; + @SerializedName(SERIALIZED_NAME_PRICING_CURRENCY) + @javax.annotation.Nullable + private String pricingCurrency; + + public static final String SERIALIZED_NAME_MONTHLY_COST_LOCAL = "monthlyCostLocal"; + @SerializedName(SERIALIZED_NAME_MONTHLY_COST_LOCAL) + @javax.annotation.Nullable + private Double monthlyCostLocal; + + public static final String SERIALIZED_NAME_YEARLY_COST_LOCAL = "yearlyCostLocal"; + @SerializedName(SERIALIZED_NAME_YEARLY_COST_LOCAL) + @javax.annotation.Nullable + private Double yearlyCostLocal; + public static final String SERIALIZED_NAME_MONTHLY_STRIPE_PLAN_ID = "monthlyStripePlanId"; @SerializedName(SERIALIZED_NAME_MONTHLY_STRIPE_PLAN_ID) @javax.annotation.Nullable @@ -467,7 +482,7 @@ public TenantPackage monthlyCostUSD(@javax.annotation.Nullable Double monthlyCos } /** - * Get monthlyCostUSD + * Always the USD list price, also on regionally priced tenants (commissions and plan comparisons read it). * @return monthlyCostUSD */ @javax.annotation.Nullable @@ -499,6 +514,63 @@ public void setYearlyCostUSD(@javax.annotation.Nullable Double yearlyCostUSD) { } + public TenantPackage pricingCurrency(@javax.annotation.Nullable String pricingCurrency) { + this.pricingCurrency = pricingCurrency; + return this; + } + + /** + * Regional prices the tenant is charged, when pricingCurrency is set; the Stripe plan ids below are then in that currency. + * @return pricingCurrency + */ + @javax.annotation.Nullable + public String getPricingCurrency() { + return pricingCurrency; + } + + public void setPricingCurrency(@javax.annotation.Nullable String pricingCurrency) { + this.pricingCurrency = pricingCurrency; + } + + + public TenantPackage monthlyCostLocal(@javax.annotation.Nullable Double monthlyCostLocal) { + this.monthlyCostLocal = monthlyCostLocal; + return this; + } + + /** + * Get monthlyCostLocal + * @return monthlyCostLocal + */ + @javax.annotation.Nullable + public Double getMonthlyCostLocal() { + return monthlyCostLocal; + } + + public void setMonthlyCostLocal(@javax.annotation.Nullable Double monthlyCostLocal) { + this.monthlyCostLocal = monthlyCostLocal; + } + + + public TenantPackage yearlyCostLocal(@javax.annotation.Nullable Double yearlyCostLocal) { + this.yearlyCostLocal = yearlyCostLocal; + return this; + } + + /** + * Get yearlyCostLocal + * @return yearlyCostLocal + */ + @javax.annotation.Nullable + public Double getYearlyCostLocal() { + return yearlyCostLocal; + } + + public void setYearlyCostLocal(@javax.annotation.Nullable Double yearlyCostLocal) { + this.yearlyCostLocal = yearlyCostLocal; + } + + public TenantPackage monthlyStripePlanId(@javax.annotation.Nullable String monthlyStripePlanId) { this.monthlyStripePlanId = monthlyStripePlanId; return this; @@ -1551,6 +1623,50 @@ public void setAiAgentMonthlyBudgetCents(@javax.annotation.Nullable Double aiAge this.aiAgentMonthlyBudgetCents = aiAgentMonthlyBudgetCents; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TenantPackage instance itself + */ + public TenantPackage putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -1569,6 +1685,9 @@ public boolean equals(Object o) { Objects.equals(this.templateId, tenantPackage.templateId) && Objects.equals(this.monthlyCostUSD, tenantPackage.monthlyCostUSD) && Objects.equals(this.yearlyCostUSD, tenantPackage.yearlyCostUSD) && + Objects.equals(this.pricingCurrency, tenantPackage.pricingCurrency) && + Objects.equals(this.monthlyCostLocal, tenantPackage.monthlyCostLocal) && + Objects.equals(this.yearlyCostLocal, tenantPackage.yearlyCostLocal) && Objects.equals(this.monthlyStripePlanId, tenantPackage.monthlyStripePlanId) && Objects.equals(this.yearlyStripePlanId, tenantPackage.yearlyStripePlanId) && Objects.equals(this.maxMonthlyPageLoads, tenantPackage.maxMonthlyPageLoads) && @@ -1623,12 +1742,13 @@ public boolean equals(Object o) { Objects.equals(this.hasAIAgents, tenantPackage.hasAIAgents) && Objects.equals(this.maxAIAgents, tenantPackage.maxAIAgents) && Objects.equals(this.aiAgentDailyBudgetCents, tenantPackage.aiAgentDailyBudgetCents) && - Objects.equals(this.aiAgentMonthlyBudgetCents, tenantPackage.aiAgentMonthlyBudgetCents); + Objects.equals(this.aiAgentMonthlyBudgetCents, tenantPackage.aiAgentMonthlyBudgetCents)&& + Objects.equals(this.additionalProperties, tenantPackage.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, name, tenantId, createdAt, templateId, monthlyCostUSD, yearlyCostUSD, monthlyStripePlanId, yearlyStripePlanId, maxMonthlyPageLoads, maxMonthlyAPICredits, maxMonthlySmallWidgetsCredits, maxMonthlyComments, maxConcurrentUsers, maxTenantUsers, maxSSOUsers, maxModerators, maxDomains, maxWhiteLabeledTenants, maxMonthlyEventLogRequests, maxCustomCollectionSize, hasWhiteLabeling, hasDebranding, hasLLMSpamDetection, forWhoText, featureTaglines, hasAuditing, hasFlexPricing, enableSAML, enableCanvasLTI, flexPageLoadCostCents, flexPageLoadUnit, flexCommentCostCents, flexCommentUnit, flexSSOUserCostCents, flexSSOUserUnit, flexAPICreditCostCents, flexAPICreditUnit, flexSmallWidgetsCreditCostCents, flexSmallWidgetsCreditUnit, flexModeratorCostCents, flexModeratorUnit, flexAdminCostCents, flexAdminUnit, flexDomainCostCents, flexDomainUnit, flexChatGPTCostCents, flexChatGPTUnit, flexLLMCostCents, flexLLMUnit, flexMinimumCostCents, flexManagedTenantCostCents, flexSSOAdminCostCents, flexSSOAdminUnit, flexSSOModeratorCostCents, flexSSOModeratorUnit, flexFreeModerators, isSSOBillingMonthlyActiveUsers, hasAIAgents, maxAIAgents, aiAgentDailyBudgetCents, aiAgentMonthlyBudgetCents); + return Objects.hash(id, name, tenantId, createdAt, templateId, monthlyCostUSD, yearlyCostUSD, pricingCurrency, monthlyCostLocal, yearlyCostLocal, monthlyStripePlanId, yearlyStripePlanId, maxMonthlyPageLoads, maxMonthlyAPICredits, maxMonthlySmallWidgetsCredits, maxMonthlyComments, maxConcurrentUsers, maxTenantUsers, maxSSOUsers, maxModerators, maxDomains, maxWhiteLabeledTenants, maxMonthlyEventLogRequests, maxCustomCollectionSize, hasWhiteLabeling, hasDebranding, hasLLMSpamDetection, forWhoText, featureTaglines, hasAuditing, hasFlexPricing, enableSAML, enableCanvasLTI, flexPageLoadCostCents, flexPageLoadUnit, flexCommentCostCents, flexCommentUnit, flexSSOUserCostCents, flexSSOUserUnit, flexAPICreditCostCents, flexAPICreditUnit, flexSmallWidgetsCreditCostCents, flexSmallWidgetsCreditUnit, flexModeratorCostCents, flexModeratorUnit, flexAdminCostCents, flexAdminUnit, flexDomainCostCents, flexDomainUnit, flexChatGPTCostCents, flexChatGPTUnit, flexLLMCostCents, flexLLMUnit, flexMinimumCostCents, flexManagedTenantCostCents, flexSSOAdminCostCents, flexSSOAdminUnit, flexSSOModeratorCostCents, flexSSOModeratorUnit, flexFreeModerators, isSSOBillingMonthlyActiveUsers, hasAIAgents, maxAIAgents, aiAgentDailyBudgetCents, aiAgentMonthlyBudgetCents, additionalProperties); } @Override @@ -1642,6 +1762,9 @@ public String toString() { sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n"); sb.append(" monthlyCostUSD: ").append(toIndentedString(monthlyCostUSD)).append("\n"); sb.append(" yearlyCostUSD: ").append(toIndentedString(yearlyCostUSD)).append("\n"); + sb.append(" pricingCurrency: ").append(toIndentedString(pricingCurrency)).append("\n"); + sb.append(" monthlyCostLocal: ").append(toIndentedString(monthlyCostLocal)).append("\n"); + sb.append(" yearlyCostLocal: ").append(toIndentedString(yearlyCostLocal)).append("\n"); sb.append(" monthlyStripePlanId: ").append(toIndentedString(monthlyStripePlanId)).append("\n"); sb.append(" yearlyStripePlanId: ").append(toIndentedString(yearlyStripePlanId)).append("\n"); sb.append(" maxMonthlyPageLoads: ").append(toIndentedString(maxMonthlyPageLoads)).append("\n"); @@ -1697,6 +1820,7 @@ public String toString() { sb.append(" maxAIAgents: ").append(toIndentedString(maxAIAgents)).append("\n"); sb.append(" aiAgentDailyBudgetCents: ").append(toIndentedString(aiAgentDailyBudgetCents)).append("\n"); sb.append(" aiAgentMonthlyBudgetCents: ").append(toIndentedString(aiAgentMonthlyBudgetCents)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -1715,7 +1839,7 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("_id", "name", "tenantId", "createdAt", "templateId", "monthlyCostUSD", "yearlyCostUSD", "monthlyStripePlanId", "yearlyStripePlanId", "maxMonthlyPageLoads", "maxMonthlyAPICredits", "maxMonthlySmallWidgetsCredits", "maxMonthlyComments", "maxConcurrentUsers", "maxTenantUsers", "maxSSOUsers", "maxModerators", "maxDomains", "maxWhiteLabeledTenants", "maxMonthlyEventLogRequests", "maxCustomCollectionSize", "hasWhiteLabeling", "hasDebranding", "hasLLMSpamDetection", "forWhoText", "featureTaglines", "hasAuditing", "hasFlexPricing", "enableSAML", "enableCanvasLTI", "flexPageLoadCostCents", "flexPageLoadUnit", "flexCommentCostCents", "flexCommentUnit", "flexSSOUserCostCents", "flexSSOUserUnit", "flexAPICreditCostCents", "flexAPICreditUnit", "flexSmallWidgetsCreditCostCents", "flexSmallWidgetsCreditUnit", "flexModeratorCostCents", "flexModeratorUnit", "flexAdminCostCents", "flexAdminUnit", "flexDomainCostCents", "flexDomainUnit", "flexChatGPTCostCents", "flexChatGPTUnit", "flexLLMCostCents", "flexLLMUnit", "flexMinimumCostCents", "flexManagedTenantCostCents", "flexSSOAdminCostCents", "flexSSOAdminUnit", "flexSSOModeratorCostCents", "flexSSOModeratorUnit", "flexFreeModerators", "isSSOBillingMonthlyActiveUsers", "hasAIAgents", "maxAIAgents", "aiAgentDailyBudgetCents", "aiAgentMonthlyBudgetCents")); + openapiFields = new HashSet(Arrays.asList("_id", "name", "tenantId", "createdAt", "templateId", "monthlyCostUSD", "yearlyCostUSD", "pricingCurrency", "monthlyCostLocal", "yearlyCostLocal", "monthlyStripePlanId", "yearlyStripePlanId", "maxMonthlyPageLoads", "maxMonthlyAPICredits", "maxMonthlySmallWidgetsCredits", "maxMonthlyComments", "maxConcurrentUsers", "maxTenantUsers", "maxSSOUsers", "maxModerators", "maxDomains", "maxWhiteLabeledTenants", "maxMonthlyEventLogRequests", "maxCustomCollectionSize", "hasWhiteLabeling", "hasDebranding", "hasLLMSpamDetection", "forWhoText", "featureTaglines", "hasAuditing", "hasFlexPricing", "enableSAML", "enableCanvasLTI", "flexPageLoadCostCents", "flexPageLoadUnit", "flexCommentCostCents", "flexCommentUnit", "flexSSOUserCostCents", "flexSSOUserUnit", "flexAPICreditCostCents", "flexAPICreditUnit", "flexSmallWidgetsCreditCostCents", "flexSmallWidgetsCreditUnit", "flexModeratorCostCents", "flexModeratorUnit", "flexAdminCostCents", "flexAdminUnit", "flexDomainCostCents", "flexDomainUnit", "flexChatGPTCostCents", "flexChatGPTUnit", "flexLLMCostCents", "flexLLMUnit", "flexMinimumCostCents", "flexManagedTenantCostCents", "flexSSOAdminCostCents", "flexSSOAdminUnit", "flexSSOModeratorCostCents", "flexSSOModeratorUnit", "flexFreeModerators", "isSSOBillingMonthlyActiveUsers", "hasAIAgents", "maxAIAgents", "aiAgentDailyBudgetCents", "aiAgentMonthlyBudgetCents")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("_id", "name", "tenantId", "createdAt", "monthlyCostUSD", "yearlyCostUSD", "monthlyStripePlanId", "yearlyStripePlanId", "maxMonthlyPageLoads", "maxMonthlyAPICredits", "maxMonthlySmallWidgetsCredits", "maxMonthlyComments", "maxConcurrentUsers", "maxTenantUsers", "maxSSOUsers", "maxModerators", "maxDomains", "maxWhiteLabeledTenants", "maxMonthlyEventLogRequests", "maxCustomCollectionSize", "hasWhiteLabeling", "hasDebranding", "hasLLMSpamDetection", "forWhoText", "featureTaglines", "hasAuditing", "hasFlexPricing")); @@ -1734,14 +1858,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TenantPackage.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TenantPackage` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TenantPackage.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -1761,6 +1877,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if ((jsonObj.get("templateId") != null && !jsonObj.get("templateId").isJsonNull()) && !jsonObj.get("templateId").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `templateId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("templateId").toString())); } + if ((jsonObj.get("pricingCurrency") != null && !jsonObj.get("pricingCurrency").isJsonNull()) && !jsonObj.get("pricingCurrency").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `pricingCurrency` to be a primitive type in the JSON string but got `%s`", jsonObj.get("pricingCurrency").toString())); + } if ((jsonObj.get("monthlyStripePlanId") != null && !jsonObj.get("monthlyStripePlanId").isJsonNull()) && !jsonObj.get("monthlyStripePlanId").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `monthlyStripePlanId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("monthlyStripePlanId").toString())); } @@ -1793,6 +1912,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TenantPackage value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -1800,7 +1941,28 @@ public void write(JsonWriter out, TenantPackage value) throws IOException { public TenantPackage read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TenantPackage instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UnBlockFromCommentParams.java b/client/src/main/java/com/fastcomments/model/UnBlockFromCommentParams.java index 0d8eeea8..d4b2f7cd 100644 --- a/client/src/main/java/com/fastcomments/model/UnBlockFromCommentParams.java +++ b/client/src/main/java/com/fastcomments/model/UnBlockFromCommentParams.java @@ -86,6 +86,50 @@ public void setCommentIdsToCheck(@javax.annotation.Nullable List comment this.commentIdsToCheck = commentIdsToCheck; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UnBlockFromCommentParams instance itself + */ + public UnBlockFromCommentParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -97,12 +141,13 @@ public boolean equals(Object o) { return false; } UnBlockFromCommentParams unBlockFromCommentParams = (UnBlockFromCommentParams) o; - return Objects.equals(this.commentIdsToCheck, unBlockFromCommentParams.commentIdsToCheck); + return Objects.equals(this.commentIdsToCheck, unBlockFromCommentParams.commentIdsToCheck)&& + Objects.equals(this.additionalProperties, unBlockFromCommentParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(commentIdsToCheck); + return Objects.hash(commentIdsToCheck, additionalProperties); } @Override @@ -110,6 +155,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UnBlockFromCommentParams {\n"); sb.append(" commentIdsToCheck: ").append(toIndentedString(commentIdsToCheck)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -146,14 +192,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UnBlockFromCommentParams is not found in the empty JSON string", UnBlockFromCommentParams.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UnBlockFromCommentParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UnBlockFromCommentParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("commentIdsToCheck") != null && !jsonObj.get("commentIdsToCheck").isJsonNull() && !jsonObj.get("commentIdsToCheck").isJsonArray()) { @@ -176,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UnBlockFromCommentParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -183,7 +243,28 @@ public void write(JsonWriter out, UnBlockFromCommentParams value) throws IOExcep public UnBlockFromCommentParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UnBlockFromCommentParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UnblockSuccess.java b/client/src/main/java/com/fastcomments/model/UnblockSuccess.java index 9f752635..a382122b 100644 --- a/client/src/main/java/com/fastcomments/model/UnblockSuccess.java +++ b/client/src/main/java/com/fastcomments/model/UnblockSuccess.java @@ -111,6 +111,50 @@ public void setCommentStatuses(@javax.annotation.Nonnull Map co this.commentStatuses = commentStatuses; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UnblockSuccess instance itself + */ + public UnblockSuccess putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -123,12 +167,13 @@ public boolean equals(Object o) { } UnblockSuccess unblockSuccess = (UnblockSuccess) o; return Objects.equals(this.status, unblockSuccess.status) && - Objects.equals(this.commentStatuses, unblockSuccess.commentStatuses); + Objects.equals(this.commentStatuses, unblockSuccess.commentStatuses)&& + Objects.equals(this.additionalProperties, unblockSuccess.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, commentStatuses); + return Objects.hash(status, commentStatuses, additionalProperties); } @Override @@ -137,6 +182,7 @@ public String toString() { sb.append("class UnblockSuccess {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" commentStatuses: ").append(toIndentedString(commentStatuses)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -174,14 +220,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UnblockSuccess.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UnblockSuccess` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UnblockSuccess.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -208,6 +246,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UnblockSuccess value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -215,7 +275,28 @@ public void write(JsonWriter out, UnblockSuccess value) throws IOException { public UnblockSuccess read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UnblockSuccess instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UpdatableCommentParams.java b/client/src/main/java/com/fastcomments/model/UpdatableCommentParams.java index 2d4920cb..3154f46c 100644 --- a/client/src/main/java/com/fastcomments/model/UpdatableCommentParams.java +++ b/client/src/main/java/com/fastcomments/model/UpdatableCommentParams.java @@ -1008,6 +1008,50 @@ public void setFeedbackIds(@javax.annotation.Nullable List feedbackIds) this.feedbackIds = feedbackIds; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdatableCommentParams instance itself + */ + public UpdatableCommentParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -1057,12 +1101,13 @@ public boolean equals(Object o) { Objects.equals(this.displayLabel, updatableCommentParams.displayLabel) && Objects.equals(this.meta, updatableCommentParams.meta) && Objects.equals(this.moderationGroupIds, updatableCommentParams.moderationGroupIds) && - Objects.equals(this.feedbackIds, updatableCommentParams.feedbackIds); + Objects.equals(this.feedbackIds, updatableCommentParams.feedbackIds)&& + Objects.equals(this.additionalProperties, updatableCommentParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(urlId, urlIdRaw, url, pageTitle, userId, commenterEmail, commenterName, commenterLink, comment, commentHTML, parentId, date, localDateString, localDateHours, votes, votesUp, votesDown, expireAt, verified, verifiedDate, notificationSentForParent, notificationSentForParentTenant, reviewed, externalId, externalParentId, avatarSrc, isSpam, approved, isDeleted, isDeletedUser, isByAdmin, isByModerator, isPinned, isLocked, flagCount, displayLabel, meta, moderationGroupIds, feedbackIds); + return Objects.hash(urlId, urlIdRaw, url, pageTitle, userId, commenterEmail, commenterName, commenterLink, comment, commentHTML, parentId, date, localDateString, localDateHours, votes, votesUp, votesDown, expireAt, verified, verifiedDate, notificationSentForParent, notificationSentForParentTenant, reviewed, externalId, externalParentId, avatarSrc, isSpam, approved, isDeleted, isDeletedUser, isByAdmin, isByModerator, isPinned, isLocked, flagCount, displayLabel, meta, moderationGroupIds, feedbackIds, additionalProperties); } @Override @@ -1108,6 +1153,7 @@ public String toString() { sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); sb.append(" moderationGroupIds: ").append(toIndentedString(moderationGroupIds)).append("\n"); sb.append(" feedbackIds: ").append(toIndentedString(feedbackIds)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -1144,14 +1190,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UpdatableCommentParams is not found in the empty JSON string", UpdatableCommentParams.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdatableCommentParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdatableCommentParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("urlId") != null && !jsonObj.get("urlId").isJsonNull()) && !jsonObj.get("urlId").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `urlId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("urlId").toString())); @@ -1226,6 +1264,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdatableCommentParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -1233,7 +1293,28 @@ public void write(JsonWriter out, UpdatableCommentParams value) throws IOExcepti public UpdatableCommentParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdatableCommentParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UpdateDomainConfigParams.java b/client/src/main/java/com/fastcomments/model/UpdateDomainConfigParams.java index 4e19eafb..13ebd0cc 100644 --- a/client/src/main/java/com/fastcomments/model/UpdateDomainConfigParams.java +++ b/client/src/main/java/com/fastcomments/model/UpdateDomainConfigParams.java @@ -230,6 +230,50 @@ public void setEmailHeaders(@javax.annotation.Nullable Map email this.emailHeaders = emailHeaders; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateDomainConfigParams instance itself + */ + public UpdateDomainConfigParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -247,12 +291,13 @@ public boolean equals(Object o) { Objects.equals(this.logoSrc, updateDomainConfigParams.logoSrc) && Objects.equals(this.logoSrc100px, updateDomainConfigParams.logoSrc100px) && Objects.equals(this.footerUnsubscribeURL, updateDomainConfigParams.footerUnsubscribeURL) && - Objects.equals(this.emailHeaders, updateDomainConfigParams.emailHeaders); + Objects.equals(this.emailHeaders, updateDomainConfigParams.emailHeaders)&& + Objects.equals(this.additionalProperties, updateDomainConfigParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(domain, emailFromName, emailFromEmail, logoSrc, logoSrc100px, footerUnsubscribeURL, emailHeaders); + return Objects.hash(domain, emailFromName, emailFromEmail, logoSrc, logoSrc100px, footerUnsubscribeURL, emailHeaders, additionalProperties); } @Override @@ -266,6 +311,7 @@ public String toString() { sb.append(" logoSrc100px: ").append(toIndentedString(logoSrc100px)).append("\n"); sb.append(" footerUnsubscribeURL: ").append(toIndentedString(footerUnsubscribeURL)).append("\n"); sb.append(" emailHeaders: ").append(toIndentedString(emailHeaders)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -303,14 +349,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateDomainConfigParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateDomainConfigParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateDomainConfigParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -353,6 +391,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateDomainConfigParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -360,7 +420,28 @@ public void write(JsonWriter out, UpdateDomainConfigParams value) throws IOExcep public UpdateDomainConfigParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateDomainConfigParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UpdateEmailTemplateBody.java b/client/src/main/java/com/fastcomments/model/UpdateEmailTemplateBody.java index 1e4020df..0353ced9 100644 --- a/client/src/main/java/com/fastcomments/model/UpdateEmailTemplateBody.java +++ b/client/src/main/java/com/fastcomments/model/UpdateEmailTemplateBody.java @@ -214,6 +214,50 @@ public void setTestData(@javax.annotation.Nullable Map testData) this.testData = testData; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateEmailTemplateBody instance itself + */ + public UpdateEmailTemplateBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -230,12 +274,13 @@ public boolean equals(Object o) { Objects.equals(this.ejs, updateEmailTemplateBody.ejs) && Objects.equals(this.domain, updateEmailTemplateBody.domain) && Objects.equals(this.translationOverridesByLocale, updateEmailTemplateBody.translationOverridesByLocale) && - Objects.equals(this.testData, updateEmailTemplateBody.testData); + Objects.equals(this.testData, updateEmailTemplateBody.testData)&& + Objects.equals(this.additionalProperties, updateEmailTemplateBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(emailTemplateId, displayName, ejs, domain, translationOverridesByLocale, testData); + return Objects.hash(emailTemplateId, displayName, ejs, domain, translationOverridesByLocale, testData, additionalProperties); } @Override @@ -248,6 +293,7 @@ public String toString() { sb.append(" domain: ").append(toIndentedString(domain)).append("\n"); sb.append(" translationOverridesByLocale: ").append(toIndentedString(translationOverridesByLocale)).append("\n"); sb.append(" testData: ").append(toIndentedString(testData)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -284,14 +330,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UpdateEmailTemplateBody is not found in the empty JSON string", UpdateEmailTemplateBody.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateEmailTemplateBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateEmailTemplateBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("emailTemplateId") != null && !jsonObj.get("emailTemplateId").isJsonNull()) && !jsonObj.get("emailTemplateId").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `emailTemplateId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("emailTemplateId").toString())); @@ -322,6 +360,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateEmailTemplateBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -329,7 +389,28 @@ public void write(JsonWriter out, UpdateEmailTemplateBody value) throws IOExcept public UpdateEmailTemplateBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateEmailTemplateBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UpdateFeedPostParams.java b/client/src/main/java/com/fastcomments/model/UpdateFeedPostParams.java index c8bf5ecc..16f85cc4 100644 --- a/client/src/main/java/com/fastcomments/model/UpdateFeedPostParams.java +++ b/client/src/main/java/com/fastcomments/model/UpdateFeedPostParams.java @@ -234,6 +234,50 @@ public void setMeta(@javax.annotation.Nullable Map meta) { this.meta = meta; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateFeedPostParams instance itself + */ + public UpdateFeedPostParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -250,12 +294,13 @@ public boolean equals(Object o) { Objects.equals(this.media, updateFeedPostParams.media) && Objects.equals(this.links, updateFeedPostParams.links) && Objects.equals(this.tags, updateFeedPostParams.tags) && - Objects.equals(this.meta, updateFeedPostParams.meta); + Objects.equals(this.meta, updateFeedPostParams.meta)&& + Objects.equals(this.additionalProperties, updateFeedPostParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(title, contentHTML, media, links, tags, meta); + return Objects.hash(title, contentHTML, media, links, tags, meta, additionalProperties); } @Override @@ -268,6 +313,7 @@ public String toString() { sb.append(" links: ").append(toIndentedString(links)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -304,14 +350,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UpdateFeedPostParams is not found in the empty JSON string", UpdateFeedPostParams.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateFeedPostParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateFeedPostParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("title") != null && !jsonObj.get("title").isJsonNull()) && !jsonObj.get("title").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); @@ -368,6 +406,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateFeedPostParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -375,7 +435,28 @@ public void write(JsonWriter out, UpdateFeedPostParams value) throws IOException public UpdateFeedPostParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateFeedPostParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UpdateHashTagBody.java b/client/src/main/java/com/fastcomments/model/UpdateHashTagBody.java index a48f9e10..dbf77995 100644 --- a/client/src/main/java/com/fastcomments/model/UpdateHashTagBody.java +++ b/client/src/main/java/com/fastcomments/model/UpdateHashTagBody.java @@ -124,6 +124,50 @@ public void setTag(@javax.annotation.Nullable String tag) { this.tag = tag; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateHashTagBody instance itself + */ + public UpdateHashTagBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -137,12 +181,13 @@ public boolean equals(Object o) { UpdateHashTagBody updateHashTagBody = (UpdateHashTagBody) o; return Objects.equals(this.tenantId, updateHashTagBody.tenantId) && Objects.equals(this.url, updateHashTagBody.url) && - Objects.equals(this.tag, updateHashTagBody.tag); + Objects.equals(this.tag, updateHashTagBody.tag)&& + Objects.equals(this.additionalProperties, updateHashTagBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tenantId, url, tag); + return Objects.hash(tenantId, url, tag, additionalProperties); } @Override @@ -152,6 +197,7 @@ public String toString() { sb.append(" tenantId: ").append(toIndentedString(tenantId)).append("\n"); sb.append(" url: ").append(toIndentedString(url)).append("\n"); sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -188,14 +234,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UpdateHashTagBody is not found in the empty JSON string", UpdateHashTagBody.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateHashTagBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateHashTagBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("tenantId") != null && !jsonObj.get("tenantId").isJsonNull()) && !jsonObj.get("tenantId").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `tenantId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tenantId").toString())); @@ -223,6 +261,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateHashTagBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -230,7 +290,28 @@ public void write(JsonWriter out, UpdateHashTagBody value) throws IOException { public UpdateHashTagBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateHashTagBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UpdateHashTagResponse.java b/client/src/main/java/com/fastcomments/model/UpdateHashTagResponse.java index 2ef47d67..d5ec5bca 100644 --- a/client/src/main/java/com/fastcomments/model/UpdateHashTagResponse.java +++ b/client/src/main/java/com/fastcomments/model/UpdateHashTagResponse.java @@ -102,6 +102,50 @@ public void setHashTag(@javax.annotation.Nonnull TenantHashTag hashTag) { this.hashTag = hashTag; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateHashTagResponse instance itself + */ + public UpdateHashTagResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -114,12 +158,13 @@ public boolean equals(Object o) { } UpdateHashTagResponse updateHashTagResponse = (UpdateHashTagResponse) o; return Objects.equals(this.status, updateHashTagResponse.status) && - Objects.equals(this.hashTag, updateHashTagResponse.hashTag); + Objects.equals(this.hashTag, updateHashTagResponse.hashTag)&& + Objects.equals(this.additionalProperties, updateHashTagResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, hashTag); + return Objects.hash(status, hashTag, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class UpdateHashTagResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" hashTag: ").append(toIndentedString(hashTag)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -165,14 +211,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateHashTagResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateHashTagResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateHashTagResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -201,6 +239,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateHashTagResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -208,7 +268,28 @@ public void write(JsonWriter out, UpdateHashTagResponse value) throws IOExceptio public UpdateHashTagResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateHashTagResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UpdateTenantBody.java b/client/src/main/java/com/fastcomments/model/UpdateTenantBody.java index 145ce506..8491a4b2 100644 --- a/client/src/main/java/com/fastcomments/model/UpdateTenantBody.java +++ b/client/src/main/java/com/fastcomments/model/UpdateTenantBody.java @@ -626,6 +626,50 @@ public void setManagedByTenantId(@javax.annotation.Nullable String managedByTena this.managedByTenantId = managedByTenantId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateTenantBody instance itself + */ + public UpdateTenantBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -659,12 +703,13 @@ public boolean equals(Object o) { Objects.equals(this.sendProfaneToSpam, updateTenantBody.sendProfaneToSpam) && Objects.equals(this.deAnonIpAddr, updateTenantBody.deAnonIpAddr) && Objects.equals(this.meta, updateTenantBody.meta) && - Objects.equals(this.managedByTenantId, updateTenantBody.managedByTenantId); + Objects.equals(this.managedByTenantId, updateTenantBody.managedByTenantId)&& + Objects.equals(this.additionalProperties, updateTenantBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, email, signUpDate, packageId, paymentFrequency, billingInfoValid, billingHandledExternally, isSetup, domainConfiguration, billingInfo, stripeCustomerId, stripeSubscriptionId, stripePlanId, enableProfanityFilter, enableSpamFilter, removeUnverifiedComments, unverifiedCommentsTTLms, commentsRequireApproval, autoApproveCommentOnVerification, sendProfaneToSpam, deAnonIpAddr, meta, managedByTenantId); + return Objects.hash(name, email, signUpDate, packageId, paymentFrequency, billingInfoValid, billingHandledExternally, isSetup, domainConfiguration, billingInfo, stripeCustomerId, stripeSubscriptionId, stripePlanId, enableProfanityFilter, enableSpamFilter, removeUnverifiedComments, unverifiedCommentsTTLms, commentsRequireApproval, autoApproveCommentOnVerification, sendProfaneToSpam, deAnonIpAddr, meta, managedByTenantId, additionalProperties); } @Override @@ -694,6 +739,7 @@ public String toString() { sb.append(" deAnonIpAddr: ").append(toIndentedString(deAnonIpAddr)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); sb.append(" managedByTenantId: ").append(toIndentedString(managedByTenantId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -730,14 +776,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UpdateTenantBody is not found in the empty JSON string", UpdateTenantBody.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateTenantBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateTenantBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -795,6 +833,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateTenantBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -802,7 +862,28 @@ public void write(JsonWriter out, UpdateTenantBody value) throws IOException { public UpdateTenantBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateTenantBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UpdateTenantPackageBody.java b/client/src/main/java/com/fastcomments/model/UpdateTenantPackageBody.java index 18c4fd1e..ea8f7317 100644 --- a/client/src/main/java/com/fastcomments/model/UpdateTenantPackageBody.java +++ b/client/src/main/java/com/fastcomments/model/UpdateTenantPackageBody.java @@ -830,6 +830,50 @@ public void setFlexMinimumCostCents(@javax.annotation.Nullable Double flexMinimu this.flexMinimumCostCents = flexMinimumCostCents; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateTenantPackageBody instance itself + */ + public UpdateTenantPackageBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -872,12 +916,13 @@ public boolean equals(Object o) { Objects.equals(this.flexAdminUnit, updateTenantPackageBody.flexAdminUnit) && Objects.equals(this.flexDomainCostCents, updateTenantPackageBody.flexDomainCostCents) && Objects.equals(this.flexDomainUnit, updateTenantPackageBody.flexDomainUnit) && - Objects.equals(this.flexMinimumCostCents, updateTenantPackageBody.flexMinimumCostCents); + Objects.equals(this.flexMinimumCostCents, updateTenantPackageBody.flexMinimumCostCents)&& + Objects.equals(this.additionalProperties, updateTenantPackageBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, monthlyCostUSD, yearlyCostUSD, maxMonthlyPageLoads, maxMonthlyAPICredits, maxMonthlyComments, maxConcurrentUsers, maxTenantUsers, maxSSOUsers, maxModerators, maxDomains, maxCustomCollectionSize, hasDebranding, hasWhiteLabeling, forWhoText, featureTaglines, hasFlexPricing, flexPageLoadCostCents, flexPageLoadUnit, flexCommentCostCents, flexCommentUnit, flexSSOUserCostCents, flexSSOUserUnit, flexAPICreditCostCents, flexAPICreditUnit, flexModeratorCostCents, flexModeratorUnit, flexAdminCostCents, flexAdminUnit, flexDomainCostCents, flexDomainUnit, flexMinimumCostCents); + return Objects.hash(name, monthlyCostUSD, yearlyCostUSD, maxMonthlyPageLoads, maxMonthlyAPICredits, maxMonthlyComments, maxConcurrentUsers, maxTenantUsers, maxSSOUsers, maxModerators, maxDomains, maxCustomCollectionSize, hasDebranding, hasWhiteLabeling, forWhoText, featureTaglines, hasFlexPricing, flexPageLoadCostCents, flexPageLoadUnit, flexCommentCostCents, flexCommentUnit, flexSSOUserCostCents, flexSSOUserUnit, flexAPICreditCostCents, flexAPICreditUnit, flexModeratorCostCents, flexModeratorUnit, flexAdminCostCents, flexAdminUnit, flexDomainCostCents, flexDomainUnit, flexMinimumCostCents, additionalProperties); } @Override @@ -916,6 +961,7 @@ public String toString() { sb.append(" flexDomainCostCents: ").append(toIndentedString(flexDomainCostCents)).append("\n"); sb.append(" flexDomainUnit: ").append(toIndentedString(flexDomainUnit)).append("\n"); sb.append(" flexMinimumCostCents: ").append(toIndentedString(flexMinimumCostCents)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -952,14 +998,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UpdateTenantPackageBody is not found in the empty JSON string", UpdateTenantPackageBody.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateTenantPackageBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateTenantPackageBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -988,6 +1026,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateTenantPackageBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -995,7 +1055,28 @@ public void write(JsonWriter out, UpdateTenantPackageBody value) throws IOExcept public UpdateTenantPackageBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateTenantPackageBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UpdateTenantUserBody.java b/client/src/main/java/com/fastcomments/model/UpdateTenantUserBody.java index 3b94f3d1..7ea2d6a4 100644 --- a/client/src/main/java/com/fastcomments/model/UpdateTenantUserBody.java +++ b/client/src/main/java/com/fastcomments/model/UpdateTenantUserBody.java @@ -638,6 +638,50 @@ public void setDisplayLabel(@javax.annotation.Nullable String displayLabel) { this.displayLabel = displayLabel; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateTenantUserBody instance itself + */ + public UpdateTenantUserBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -672,12 +716,13 @@ public boolean equals(Object o) { Objects.equals(this.moderatorIds, updateTenantUserBody.moderatorIds) && Objects.equals(this.locale, updateTenantUserBody.locale) && Objects.equals(this.digestEmailFrequency, updateTenantUserBody.digestEmailFrequency) && - Objects.equals(this.displayLabel, updateTenantUserBody.displayLabel); + Objects.equals(this.displayLabel, updateTenantUserBody.displayLabel)&& + Objects.equals(this.additionalProperties, updateTenantUserBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(username, displayName, websiteUrl, email, signUpDate, verified, loginCount, optedInNotifications, optedInTenantNotifications, hideAccountCode, avatarSrc, isHelpRequestAdmin, isAccountOwner, isAdminAdmin, isBillingAdmin, isAnalyticsAdmin, isCustomizationAdmin, isManageDataAdmin, isCommentModeratorAdmin, isAPIAdmin, moderatorIds, locale, digestEmailFrequency, displayLabel); + return Objects.hash(username, displayName, websiteUrl, email, signUpDate, verified, loginCount, optedInNotifications, optedInTenantNotifications, hideAccountCode, avatarSrc, isHelpRequestAdmin, isAccountOwner, isAdminAdmin, isBillingAdmin, isAnalyticsAdmin, isCustomizationAdmin, isManageDataAdmin, isCommentModeratorAdmin, isAPIAdmin, moderatorIds, locale, digestEmailFrequency, displayLabel, additionalProperties); } @Override @@ -708,6 +753,7 @@ public String toString() { sb.append(" locale: ").append(toIndentedString(locale)).append("\n"); sb.append(" digestEmailFrequency: ").append(toIndentedString(digestEmailFrequency)).append("\n"); sb.append(" displayLabel: ").append(toIndentedString(displayLabel)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -744,14 +790,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UpdateTenantUserBody is not found in the empty JSON string", UpdateTenantUserBody.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateTenantUserBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateTenantUserBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); @@ -795,6 +833,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateTenantUserBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -802,7 +862,28 @@ public void write(JsonWriter out, UpdateTenantUserBody value) throws IOException public UpdateTenantUserBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateTenantUserBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UpdateUserBadgeParams.java b/client/src/main/java/com/fastcomments/model/UpdateUserBadgeParams.java index acaa2654..13e40439 100644 --- a/client/src/main/java/com/fastcomments/model/UpdateUserBadgeParams.java +++ b/client/src/main/java/com/fastcomments/model/UpdateUserBadgeParams.java @@ -76,6 +76,50 @@ public void setDisplayedOnComments(@javax.annotation.Nullable Boolean displayedO this.displayedOnComments = displayedOnComments; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UpdateUserBadgeParams instance itself + */ + public UpdateUserBadgeParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -87,12 +131,13 @@ public boolean equals(Object o) { return false; } UpdateUserBadgeParams updateUserBadgeParams = (UpdateUserBadgeParams) o; - return Objects.equals(this.displayedOnComments, updateUserBadgeParams.displayedOnComments); + return Objects.equals(this.displayedOnComments, updateUserBadgeParams.displayedOnComments)&& + Objects.equals(this.additionalProperties, updateUserBadgeParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(displayedOnComments); + return Objects.hash(displayedOnComments, additionalProperties); } @Override @@ -100,6 +145,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UpdateUserBadgeParams {\n"); sb.append(" displayedOnComments: ").append(toIndentedString(displayedOnComments)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -136,14 +182,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UpdateUserBadgeParams is not found in the empty JSON string", UpdateUserBadgeParams.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateUserBadgeParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateUserBadgeParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -162,6 +200,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateUserBadgeParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -169,7 +229,28 @@ public void write(JsonWriter out, UpdateUserBadgeParams value) throws IOExceptio public UpdateUserBadgeParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateUserBadgeParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UploadImageResponse.java b/client/src/main/java/com/fastcomments/model/UploadImageResponse.java index 0960d34a..d6c40a7d 100644 --- a/client/src/main/java/com/fastcomments/model/UploadImageResponse.java +++ b/client/src/main/java/com/fastcomments/model/UploadImageResponse.java @@ -184,6 +184,50 @@ public void setCode(@javax.annotation.Nullable String code) { this.code = code; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UploadImageResponse instance itself + */ + public UploadImageResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -199,12 +243,13 @@ public boolean equals(Object o) { Objects.equals(this.url, uploadImageResponse.url) && Objects.equals(this.media, uploadImageResponse.media) && Objects.equals(this.reason, uploadImageResponse.reason) && - Objects.equals(this.code, uploadImageResponse.code); + Objects.equals(this.code, uploadImageResponse.code)&& + Objects.equals(this.additionalProperties, uploadImageResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, url, media, reason, code); + return Objects.hash(status, url, media, reason, code, additionalProperties); } @Override @@ -216,6 +261,7 @@ public String toString() { sb.append(" media: ").append(toIndentedString(media)).append("\n"); sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -253,14 +299,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UploadImageResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UploadImageResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UploadImageResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -310,6 +348,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UploadImageResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -317,7 +377,28 @@ public void write(JsonWriter out, UploadImageResponse value) throws IOException public UploadImageResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UploadImageResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/User.java b/client/src/main/java/com/fastcomments/model/User.java index 9d1e8f9c..b7aa3917 100644 --- a/client/src/main/java/com/fastcomments/model/User.java +++ b/client/src/main/java/com/fastcomments/model/User.java @@ -1513,6 +1513,50 @@ public void setIsEmailSuppressed(@javax.annotation.Nullable Boolean isEmailSuppr this.isEmailSuppressed = isEmailSuppressed; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the User instance itself + */ + public User putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -1583,12 +1627,13 @@ public boolean equals(Object o) { Objects.equals(this.countryFlag, user.countryFlag) && Objects.equals(this.socialLinks, user.socialLinks) && Objects.equals(this.hasTwoFactor, user.hasTwoFactor) && - Objects.equals(this.isEmailSuppressed, user.isEmailSuppressed); + Objects.equals(this.isEmailSuppressed, user.isEmailSuppressed)&& + Objects.equals(this.additionalProperties, user.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, username, displayName, websiteUrl, email, pendingEmail, backupEmail, pendingBackupEmail, signUpDate, createdFromUrlId, createdFromTenantId, createdFromIpHashed, verified, loginId, loginIdDate, loginCount, optedInNotifications, optedInTenantNotifications, hideAccountCode, avatarSrc, isFastCommentsHelpRequestAdmin, isHelpRequestAdmin, isAccountOwner, isAdminAdmin, isBillingAdmin, isAnalyticsAdmin, isCustomizationAdmin, isManageDataAdmin, isCommentModeratorAdmin, isAPIAdmin, isSiteAdmin, moderatorIds, isImpersonator, isCouponManager, locale, digestEmailFrequency, notificationFrequency, adminNotificationFrequency, agentApprovalNotificationFrequency, lastTenantNotificationSentDate, lastReplyNotificationSentDate, ignoredAddToMySiteMessages, lastLoginDate, displayLabel, isProfileActivityPrivate, isProfileCommentsPrivate, isProfileDMDisabled, profileCommentApprovalMode, karma, passwordHash, averageTicketAckTimeMS, hasBlockedUsers, bio, headerBackgroundSrc, countryCode, countryFlag, socialLinks, hasTwoFactor, isEmailSuppressed); + return Objects.hash(id, tenantId, username, displayName, websiteUrl, email, pendingEmail, backupEmail, pendingBackupEmail, signUpDate, createdFromUrlId, createdFromTenantId, createdFromIpHashed, verified, loginId, loginIdDate, loginCount, optedInNotifications, optedInTenantNotifications, hideAccountCode, avatarSrc, isFastCommentsHelpRequestAdmin, isHelpRequestAdmin, isAccountOwner, isAdminAdmin, isBillingAdmin, isAnalyticsAdmin, isCustomizationAdmin, isManageDataAdmin, isCommentModeratorAdmin, isAPIAdmin, isSiteAdmin, moderatorIds, isImpersonator, isCouponManager, locale, digestEmailFrequency, notificationFrequency, adminNotificationFrequency, agentApprovalNotificationFrequency, lastTenantNotificationSentDate, lastReplyNotificationSentDate, ignoredAddToMySiteMessages, lastLoginDate, displayLabel, isProfileActivityPrivate, isProfileCommentsPrivate, isProfileDMDisabled, profileCommentApprovalMode, karma, passwordHash, averageTicketAckTimeMS, hasBlockedUsers, bio, headerBackgroundSrc, countryCode, countryFlag, socialLinks, hasTwoFactor, isEmailSuppressed, additionalProperties); } @Override @@ -1655,6 +1700,7 @@ public String toString() { sb.append(" socialLinks: ").append(toIndentedString(socialLinks)).append("\n"); sb.append(" hasTwoFactor: ").append(toIndentedString(hasTwoFactor)).append("\n"); sb.append(" isEmailSuppressed: ").append(toIndentedString(isEmailSuppressed)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -1692,14 +1738,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!User.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `User` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : User.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -1803,6 +1841,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, User value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -1810,7 +1870,28 @@ public void write(JsonWriter out, User value) throws IOException { public User read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + User instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UserBadge.java b/client/src/main/java/com/fastcomments/model/UserBadge.java index 645f0be7..0cb09b68 100644 --- a/client/src/main/java/com/fastcomments/model/UserBadge.java +++ b/client/src/main/java/com/fastcomments/model/UserBadge.java @@ -509,6 +509,50 @@ public void setUrlId(@javax.annotation.Nullable String urlId) { this.urlId = urlId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UserBadge instance itself + */ + public UserBadge putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -538,12 +582,13 @@ public boolean equals(Object o) { Objects.equals(this.displayedOnComments, userBadge.displayedOnComments) && Objects.equals(this.receivedAt, userBadge.receivedAt) && Objects.equals(this.order, userBadge.order) && - Objects.equals(this.urlId, userBadge.urlId); + Objects.equals(this.urlId, userBadge.urlId)&& + Objects.equals(this.additionalProperties, userBadge.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, userId, badgeId, fromTenantId, createdAt, type, threshold, description, displayLabel, displaySrc, backgroundColor, borderColor, textColor, cssClass, veteranUserThresholdMillis, displayedOnComments, receivedAt, order, urlId); + return Objects.hash(id, userId, badgeId, fromTenantId, createdAt, type, threshold, description, displayLabel, displaySrc, backgroundColor, borderColor, textColor, cssClass, veteranUserThresholdMillis, displayedOnComments, receivedAt, order, urlId, additionalProperties); } @Override @@ -569,6 +614,7 @@ public String toString() { sb.append(" receivedAt: ").append(toIndentedString(receivedAt)).append("\n"); sb.append(" order: ").append(toIndentedString(order)).append("\n"); sb.append(" urlId: ").append(toIndentedString(urlId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -606,14 +652,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UserBadge.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UserBadge` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UserBadge.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -674,6 +712,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UserBadge value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -681,7 +741,28 @@ public void write(JsonWriter out, UserBadge value) throws IOException { public UserBadge read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UserBadge instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UserBadgeProgress.java b/client/src/main/java/com/fastcomments/model/UserBadgeProgress.java index af93be0a..4a5e5d62 100644 --- a/client/src/main/java/com/fastcomments/model/UserBadgeProgress.java +++ b/client/src/main/java/com/fastcomments/model/UserBadgeProgress.java @@ -279,6 +279,50 @@ public void setTosAcceptedAt(@javax.annotation.Nullable OffsetDateTime tosAccept this.tosAcceptedAt = tosAcceptedAt; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UserBadgeProgress instance itself + */ + public UserBadgeProgress putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -298,12 +342,13 @@ public boolean equals(Object o) { Objects.equals(this.autoTrustFactor, userBadgeProgress.autoTrustFactor) && Objects.equals(this.manualTrustFactor, userBadgeProgress.manualTrustFactor) && Objects.equals(this.progress, userBadgeProgress.progress) && - Objects.equals(this.tosAcceptedAt, userBadgeProgress.tosAcceptedAt); + Objects.equals(this.tosAcceptedAt, userBadgeProgress.tosAcceptedAt)&& + Objects.equals(this.additionalProperties, userBadgeProgress.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, userId, firstCommentId, firstCommentDate, autoTrustFactor, manualTrustFactor, progress, tosAcceptedAt); + return Objects.hash(id, tenantId, userId, firstCommentId, firstCommentDate, autoTrustFactor, manualTrustFactor, progress, tosAcceptedAt, additionalProperties); } @Override @@ -319,6 +364,7 @@ public String toString() { sb.append(" manualTrustFactor: ").append(toIndentedString(manualTrustFactor)).append("\n"); sb.append(" progress: ").append(toIndentedString(progress)).append("\n"); sb.append(" tosAcceptedAt: ").append(toIndentedString(tosAcceptedAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -356,14 +402,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UserBadgeProgress.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UserBadgeProgress` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UserBadgeProgress.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -400,6 +438,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UserBadgeProgress value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -407,7 +467,28 @@ public void write(JsonWriter out, UserBadgeProgress value) throws IOException { public UserBadgeProgress read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UserBadgeProgress instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UserNotification.java b/client/src/main/java/com/fastcomments/model/UserNotification.java index aeb6d942..67bf39ef 100644 --- a/client/src/main/java/com/fastcomments/model/UserNotification.java +++ b/client/src/main/java/com/fastcomments/model/UserNotification.java @@ -657,6 +657,50 @@ public void setFromUserNames(@javax.annotation.Nullable List fromUserNam this.fromUserNames = fromUserNames; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UserNotification instance itself + */ + public UserNotification putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -691,12 +735,13 @@ public boolean equals(Object o) { Objects.equals(this.count, userNotification.count) && Objects.equals(this.relatedIds, userNotification.relatedIds) && Objects.equals(this.fromUserIds, userNotification.fromUserIds) && - Objects.equals(this.fromUserNames, userNotification.fromUserNames); + Objects.equals(this.fromUserNames, userNotification.fromUserNames)&& + Objects.equals(this.additionalProperties, userNotification.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, tenantId, userId, anonUserId, urlId, url, pageTitle, relatedObjectType, relatedObjectId, viewed, isUnreadMessage, sent, createdAt, type, fromCommentId, fromVoteId, fromUserName, fromUserId, fromUserAvatarSrc, optedOut, count, relatedIds, fromUserIds, fromUserNames); + return Objects.hash(id, tenantId, userId, anonUserId, urlId, url, pageTitle, relatedObjectType, relatedObjectId, viewed, isUnreadMessage, sent, createdAt, type, fromCommentId, fromVoteId, fromUserName, fromUserId, fromUserAvatarSrc, optedOut, count, relatedIds, fromUserIds, fromUserNames, additionalProperties); } @Override @@ -727,6 +772,7 @@ public String toString() { sb.append(" relatedIds: ").append(toIndentedString(relatedIds)).append("\n"); sb.append(" fromUserIds: ").append(toIndentedString(fromUserIds)).append("\n"); sb.append(" fromUserNames: ").append(toIndentedString(fromUserNames)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -764,14 +810,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UserNotification.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UserNotification` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UserNotification.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -851,6 +889,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UserNotification value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -858,7 +918,28 @@ public void write(JsonWriter out, UserNotification value) throws IOException { public UserNotification read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UserNotification instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UserNotificationCount.java b/client/src/main/java/com/fastcomments/model/UserNotificationCount.java index 892b21a0..6273606c 100644 --- a/client/src/main/java/com/fastcomments/model/UserNotificationCount.java +++ b/client/src/main/java/com/fastcomments/model/UserNotificationCount.java @@ -149,6 +149,50 @@ public void setExpireAt(@javax.annotation.Nonnull OffsetDateTime expireAt) { this.expireAt = expireAt; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UserNotificationCount instance itself + */ + public UserNotificationCount putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -163,12 +207,13 @@ public boolean equals(Object o) { return Objects.equals(this.id, userNotificationCount.id) && Objects.equals(this.count, userNotificationCount.count) && Objects.equals(this.createdAt, userNotificationCount.createdAt) && - Objects.equals(this.expireAt, userNotificationCount.expireAt); + Objects.equals(this.expireAt, userNotificationCount.expireAt)&& + Objects.equals(this.additionalProperties, userNotificationCount.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, count, createdAt, expireAt); + return Objects.hash(id, count, createdAt, expireAt, additionalProperties); } @Override @@ -179,6 +224,7 @@ public String toString() { sb.append(" count: ").append(toIndentedString(count)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); sb.append(" expireAt: ").append(toIndentedString(expireAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -216,14 +262,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UserNotificationCount.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UserNotificationCount` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UserNotificationCount.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -251,6 +289,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UserNotificationCount value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -258,7 +318,28 @@ public void write(JsonWriter out, UserNotificationCount value) throws IOExceptio public UserNotificationCount read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UserNotificationCount instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UserNotificationWriteResponse.java b/client/src/main/java/com/fastcomments/model/UserNotificationWriteResponse.java index cd9bd43f..5f374ec4 100644 --- a/client/src/main/java/com/fastcomments/model/UserNotificationWriteResponse.java +++ b/client/src/main/java/com/fastcomments/model/UserNotificationWriteResponse.java @@ -125,6 +125,50 @@ public void setModifiedCount(@javax.annotation.Nonnull Long modifiedCount) { this.modifiedCount = modifiedCount; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UserNotificationWriteResponse instance itself + */ + public UserNotificationWriteResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -138,12 +182,13 @@ public boolean equals(Object o) { UserNotificationWriteResponse userNotificationWriteResponse = (UserNotificationWriteResponse) o; return Objects.equals(this.status, userNotificationWriteResponse.status) && Objects.equals(this.matchedCount, userNotificationWriteResponse.matchedCount) && - Objects.equals(this.modifiedCount, userNotificationWriteResponse.modifiedCount); + Objects.equals(this.modifiedCount, userNotificationWriteResponse.modifiedCount)&& + Objects.equals(this.additionalProperties, userNotificationWriteResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, matchedCount, modifiedCount); + return Objects.hash(status, matchedCount, modifiedCount, additionalProperties); } @Override @@ -153,6 +198,7 @@ public String toString() { sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" matchedCount: ").append(toIndentedString(matchedCount)).append("\n"); sb.append(" modifiedCount: ").append(toIndentedString(modifiedCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -190,14 +236,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UserNotificationWriteResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UserNotificationWriteResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UserNotificationWriteResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -224,6 +262,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UserNotificationWriteResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -231,7 +291,28 @@ public void write(JsonWriter out, UserNotificationWriteResponse value) throws IO public UserNotificationWriteResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UserNotificationWriteResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UserReactsResponse.java b/client/src/main/java/com/fastcomments/model/UserReactsResponse.java index 5a263544..182eceb4 100644 --- a/client/src/main/java/com/fastcomments/model/UserReactsResponse.java +++ b/client/src/main/java/com/fastcomments/model/UserReactsResponse.java @@ -111,6 +111,50 @@ public void setReacts(@javax.annotation.Nonnull Map this.reacts = reacts; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UserReactsResponse instance itself + */ + public UserReactsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -123,12 +167,13 @@ public boolean equals(Object o) { } UserReactsResponse userReactsResponse = (UserReactsResponse) o; return Objects.equals(this.status, userReactsResponse.status) && - Objects.equals(this.reacts, userReactsResponse.reacts); + Objects.equals(this.reacts, userReactsResponse.reacts)&& + Objects.equals(this.additionalProperties, userReactsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, reacts); + return Objects.hash(status, reacts, additionalProperties); } @Override @@ -137,6 +182,7 @@ public String toString() { sb.append("class UserReactsResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" reacts: ").append(toIndentedString(reacts)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -174,14 +220,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UserReactsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UserReactsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UserReactsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -208,6 +246,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UserReactsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -215,7 +275,28 @@ public void write(JsonWriter out, UserReactsResponse value) throws IOException { public UserReactsResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UserReactsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UserSearchResult.java b/client/src/main/java/com/fastcomments/model/UserSearchResult.java index 1cb797f4..562ef2b5 100644 --- a/client/src/main/java/com/fastcomments/model/UserSearchResult.java +++ b/client/src/main/java/com/fastcomments/model/UserSearchResult.java @@ -224,6 +224,50 @@ public void setType(@javax.annotation.Nonnull TypeEnum type) { this.type = type; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UserSearchResult instance itself + */ + public UserSearchResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -239,12 +283,13 @@ public boolean equals(Object o) { Objects.equals(this.name, userSearchResult.name) && Objects.equals(this.displayName, userSearchResult.displayName) && Objects.equals(this.avatarSrc, userSearchResult.avatarSrc) && - Objects.equals(this.type, userSearchResult.type); + Objects.equals(this.type, userSearchResult.type)&& + Objects.equals(this.additionalProperties, userSearchResult.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, name, displayName, avatarSrc, type); + return Objects.hash(id, name, displayName, avatarSrc, type, additionalProperties); } @Override @@ -256,6 +301,7 @@ public String toString() { sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); sb.append(" avatarSrc: ").append(toIndentedString(avatarSrc)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -293,14 +339,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UserSearchResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UserSearchResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UserSearchResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -342,6 +380,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UserSearchResult value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -349,7 +409,28 @@ public void write(JsonWriter out, UserSearchResult value) throws IOException { public UserSearchResult read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UserSearchResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UserSearchSectionResult.java b/client/src/main/java/com/fastcomments/model/UserSearchSectionResult.java index 2a931fa3..c678c439 100644 --- a/client/src/main/java/com/fastcomments/model/UserSearchSectionResult.java +++ b/client/src/main/java/com/fastcomments/model/UserSearchSectionResult.java @@ -112,6 +112,50 @@ public void setUsers(@javax.annotation.Nonnull List users) { this.users = users; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UserSearchSectionResult instance itself + */ + public UserSearchSectionResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -124,12 +168,13 @@ public boolean equals(Object o) { } UserSearchSectionResult userSearchSectionResult = (UserSearchSectionResult) o; return Objects.equals(this.section, userSearchSectionResult.section) && - Objects.equals(this.users, userSearchSectionResult.users); + Objects.equals(this.users, userSearchSectionResult.users)&& + Objects.equals(this.additionalProperties, userSearchSectionResult.additionalProperties); } @Override public int hashCode() { - return Objects.hash(section, users); + return Objects.hash(section, users, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class UserSearchSectionResult {\n"); sb.append(" section: ").append(toIndentedString(section)).append("\n"); sb.append(" users: ").append(toIndentedString(users)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -175,14 +221,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UserSearchSectionResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UserSearchSectionResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UserSearchSectionResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -219,6 +257,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UserSearchSectionResult value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -226,7 +286,28 @@ public void write(JsonWriter out, UserSearchSectionResult value) throws IOExcept public UserSearchSectionResult read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UserSearchSectionResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/UserSessionInfo.java b/client/src/main/java/com/fastcomments/model/UserSessionInfo.java index 5426387c..c486c8b9 100644 --- a/client/src/main/java/com/fastcomments/model/UserSessionInfo.java +++ b/client/src/main/java/com/fastcomments/model/UserSessionInfo.java @@ -407,6 +407,50 @@ public void setWebsiteUrl(@javax.annotation.Nullable String websiteUrl) { this.websiteUrl = websiteUrl; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the UserSessionInfo instance itself + */ + public UserSessionInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -431,12 +475,13 @@ public boolean equals(Object o) { Objects.equals(this.needsTOS, userSessionInfo.needsTOS) && Objects.equals(this.sessionId, userSessionInfo.sessionId) && Objects.equals(this.username, userSessionInfo.username) && - Objects.equals(this.websiteUrl, userSessionInfo.websiteUrl); + Objects.equals(this.websiteUrl, userSessionInfo.websiteUrl)&& + Objects.equals(this.additionalProperties, userSessionInfo.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, authorized, avatarSrc, badges, displayLabel, displayName, email, groupIds, hasBlockedUsers, isAnonSession, needsTOS, sessionId, username, websiteUrl); + return Objects.hash(id, authorized, avatarSrc, badges, displayLabel, displayName, email, groupIds, hasBlockedUsers, isAnonSession, needsTOS, sessionId, username, websiteUrl, additionalProperties); } @Override @@ -457,6 +502,7 @@ public String toString() { sb.append(" sessionId: ").append(toIndentedString(sessionId)).append("\n"); sb.append(" username: ").append(toIndentedString(username)).append("\n"); sb.append(" websiteUrl: ").append(toIndentedString(websiteUrl)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -493,14 +539,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in UserSessionInfo is not found in the empty JSON string", UserSessionInfo.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UserSessionInfo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UserSessionInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); @@ -561,6 +599,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UserSessionInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -568,7 +628,28 @@ public void write(JsonWriter out, UserSessionInfo value) throws IOException { public UserSessionInfo read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UserSessionInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/VoteBodyParams.java b/client/src/main/java/com/fastcomments/model/VoteBodyParams.java index dcc36654..ca5c2633 100644 --- a/client/src/main/java/com/fastcomments/model/VoteBodyParams.java +++ b/client/src/main/java/com/fastcomments/model/VoteBodyParams.java @@ -200,6 +200,50 @@ public void setUrl(@javax.annotation.Nullable String url) { this.url = url; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the VoteBodyParams instance itself + */ + public VoteBodyParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -214,12 +258,13 @@ public boolean equals(Object o) { return Objects.equals(this.commenterEmail, voteBodyParams.commenterEmail) && Objects.equals(this.commenterName, voteBodyParams.commenterName) && Objects.equals(this.voteDir, voteBodyParams.voteDir) && - Objects.equals(this.url, voteBodyParams.url); + Objects.equals(this.url, voteBodyParams.url)&& + Objects.equals(this.additionalProperties, voteBodyParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(commenterEmail, commenterName, voteDir, url); + return Objects.hash(commenterEmail, commenterName, voteDir, url, additionalProperties); } @Override @@ -230,6 +275,7 @@ public String toString() { sb.append(" commenterName: ").append(toIndentedString(commenterName)).append("\n"); sb.append(" voteDir: ").append(toIndentedString(voteDir)).append("\n"); sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -267,14 +313,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!VoteBodyParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `VoteBodyParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : VoteBodyParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -313,6 +351,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, VoteBodyParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -320,7 +380,28 @@ public void write(JsonWriter out, VoteBodyParams value) throws IOException { public VoteBodyParams read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + VoteBodyParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/VoteDeleteResponse.java b/client/src/main/java/com/fastcomments/model/VoteDeleteResponse.java index d909a619..8b5e8af7 100644 --- a/client/src/main/java/com/fastcomments/model/VoteDeleteResponse.java +++ b/client/src/main/java/com/fastcomments/model/VoteDeleteResponse.java @@ -101,6 +101,50 @@ public void setWasPendingVote(@javax.annotation.Nullable Boolean wasPendingVote) this.wasPendingVote = wasPendingVote; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the VoteDeleteResponse instance itself + */ + public VoteDeleteResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -113,12 +157,13 @@ public boolean equals(Object o) { } VoteDeleteResponse voteDeleteResponse = (VoteDeleteResponse) o; return Objects.equals(this.status, voteDeleteResponse.status) && - Objects.equals(this.wasPendingVote, voteDeleteResponse.wasPendingVote); + Objects.equals(this.wasPendingVote, voteDeleteResponse.wasPendingVote)&& + Objects.equals(this.additionalProperties, voteDeleteResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, wasPendingVote); + return Objects.hash(status, wasPendingVote, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class VoteDeleteResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" wasPendingVote: ").append(toIndentedString(wasPendingVote)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -164,14 +210,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!VoteDeleteResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `VoteDeleteResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : VoteDeleteResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -198,6 +236,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, VoteDeleteResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -205,7 +265,28 @@ public void write(JsonWriter out, VoteDeleteResponse value) throws IOException { public VoteDeleteResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + VoteDeleteResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/VotePollBody.java b/client/src/main/java/com/fastcomments/model/VotePollBody.java index 887f22ef..8f48e321 100644 --- a/client/src/main/java/com/fastcomments/model/VotePollBody.java +++ b/client/src/main/java/com/fastcomments/model/VotePollBody.java @@ -76,6 +76,50 @@ public void setOptionId(@javax.annotation.Nonnull String optionId) { this.optionId = optionId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the VotePollBody instance itself + */ + public VotePollBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -87,12 +131,13 @@ public boolean equals(Object o) { return false; } VotePollBody votePollBody = (VotePollBody) o; - return Objects.equals(this.optionId, votePollBody.optionId); + return Objects.equals(this.optionId, votePollBody.optionId)&& + Objects.equals(this.additionalProperties, votePollBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(optionId); + return Objects.hash(optionId, additionalProperties); } @Override @@ -100,6 +145,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class VotePollBody {\n"); sb.append(" optionId: ").append(toIndentedString(optionId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -137,14 +183,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!VotePollBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `VotePollBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : VotePollBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -172,6 +210,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, VotePollBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -179,7 +239,28 @@ public void write(JsonWriter out, VotePollBody value) throws IOException { public VotePollBody read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + VotePollBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/VotePollResponse.java b/client/src/main/java/com/fastcomments/model/VotePollResponse.java index ecec26b8..d1ddbf2b 100644 --- a/client/src/main/java/com/fastcomments/model/VotePollResponse.java +++ b/client/src/main/java/com/fastcomments/model/VotePollResponse.java @@ -160,6 +160,50 @@ public void setVoterId(@javax.annotation.Nonnull String voterId) { this.voterId = voterId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the VotePollResponse instance itself + */ + public VotePollResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -174,12 +218,13 @@ public boolean equals(Object o) { return Objects.equals(this.status, votePollResponse.status) && Objects.equals(this.poll, votePollResponse.poll) && Objects.equals(this.myPollVotes, votePollResponse.myPollVotes) && - Objects.equals(this.voterId, votePollResponse.voterId); + Objects.equals(this.voterId, votePollResponse.voterId)&& + Objects.equals(this.additionalProperties, votePollResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, poll, myPollVotes, voterId); + return Objects.hash(status, poll, myPollVotes, voterId, additionalProperties); } @Override @@ -190,6 +235,7 @@ public String toString() { sb.append(" poll: ").append(toIndentedString(poll)).append("\n"); sb.append(" myPollVotes: ").append(toIndentedString(myPollVotes)).append("\n"); sb.append(" voterId: ").append(toIndentedString(voterId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -227,14 +273,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!VotePollResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `VotePollResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : VotePollResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -272,6 +310,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, VotePollResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -279,7 +339,28 @@ public void write(JsonWriter out, VotePollResponse value) throws IOException { public VotePollResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + VotePollResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/VoteResponse.java b/client/src/main/java/com/fastcomments/model/VoteResponse.java index 7a573878..48d90ec5 100644 --- a/client/src/main/java/com/fastcomments/model/VoteResponse.java +++ b/client/src/main/java/com/fastcomments/model/VoteResponse.java @@ -227,6 +227,50 @@ public void setEditKey(@javax.annotation.Nullable String editKey) { this.editKey = editKey; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the VoteResponse instance itself + */ + public VoteResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -242,12 +286,13 @@ public boolean equals(Object o) { Objects.equals(this.voteId, voteResponse.voteId) && Objects.equals(this.isVerified, voteResponse.isVerified) && Objects.equals(this.user, voteResponse.user) && - Objects.equals(this.editKey, voteResponse.editKey); + Objects.equals(this.editKey, voteResponse.editKey)&& + Objects.equals(this.additionalProperties, voteResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status, voteId, isVerified, user, editKey); + return Objects.hash(status, voteId, isVerified, user, editKey, additionalProperties); } @Override @@ -259,6 +304,7 @@ public String toString() { sb.append(" isVerified: ").append(toIndentedString(isVerified)).append("\n"); sb.append(" user: ").append(toIndentedString(user)).append("\n"); sb.append(" editKey: ").append(toIndentedString(editKey)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -296,14 +342,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!VoteResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `VoteResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : VoteResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -343,6 +381,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, VoteResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -350,7 +410,28 @@ public void write(JsonWriter out, VoteResponse value) throws IOException { public VoteResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + VoteResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/VoteResponseUser.java b/client/src/main/java/com/fastcomments/model/VoteResponseUser.java index 29d49fcc..66963572 100644 --- a/client/src/main/java/com/fastcomments/model/VoteResponseUser.java +++ b/client/src/main/java/com/fastcomments/model/VoteResponseUser.java @@ -76,6 +76,50 @@ public void setSessionId(@javax.annotation.Nullable String sessionId) { this.sessionId = sessionId; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the VoteResponseUser instance itself + */ + public VoteResponseUser putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -87,12 +131,13 @@ public boolean equals(Object o) { return false; } VoteResponseUser voteResponseUser = (VoteResponseUser) o; - return Objects.equals(this.sessionId, voteResponseUser.sessionId); + return Objects.equals(this.sessionId, voteResponseUser.sessionId)&& + Objects.equals(this.additionalProperties, voteResponseUser.additionalProperties); } @Override public int hashCode() { - return Objects.hash(sessionId); + return Objects.hash(sessionId, additionalProperties); } @Override @@ -100,6 +145,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class VoteResponseUser {\n"); sb.append(" sessionId: ").append(toIndentedString(sessionId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -136,14 +182,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in VoteResponseUser is not found in the empty JSON string", VoteResponseUser.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!VoteResponseUser.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `VoteResponseUser` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("sessionId") != null && !jsonObj.get("sessionId").isJsonNull()) && !jsonObj.get("sessionId").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `sessionId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sessionId").toString())); @@ -165,6 +203,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, VoteResponseUser value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -172,7 +232,28 @@ public void write(JsonWriter out, VoteResponseUser value) throws IOException { public VoteResponseUser read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + VoteResponseUser instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/main/java/com/fastcomments/model/WebhookComment.java b/client/src/main/java/com/fastcomments/model/WebhookComment.java index 297f600d..b8268a4d 100644 --- a/client/src/main/java/com/fastcomments/model/WebhookComment.java +++ b/client/src/main/java/com/fastcomments/model/WebhookComment.java @@ -14,6 +14,7 @@ package com.fastcomments.model; import java.util.Objects; +import com.fastcomments.model.CommentUserBadgeInfo; import com.fastcomments.model.CommentUserMentionInfo; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -198,6 +199,11 @@ public class WebhookComment { @javax.annotation.Nonnull private List moderationGroupIds = new ArrayList<>(); + public static final String SERIALIZED_NAME_BADGES = "badges"; + @SerializedName(SERIALIZED_NAME_BADGES) + @javax.annotation.Nonnull + private List badges = new ArrayList<>(); + public WebhookComment() { } @@ -768,6 +774,77 @@ public void setModerationGroupIds(@javax.annotation.Nonnull List moderat } + public WebhookComment badges(@javax.annotation.Nonnull List badges) { + this.badges = badges; + return this; + } + + public WebhookComment addBadgesItem(CommentUserBadgeInfo badgesItem) { + if (this.badges == null) { + this.badges = new ArrayList<>(); + } + this.badges.add(badgesItem); + return this; + } + + /** + * Get badges + * @return badges + */ + @javax.annotation.Nonnull + public List getBadges() { + return badges; + } + + public void setBadges(@javax.annotation.Nonnull List badges) { + this.badges = badges; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the WebhookComment instance itself + */ + public WebhookComment putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + @Override public boolean equals(Object o) { @@ -806,12 +883,14 @@ public boolean equals(Object o) { Objects.equals(this.locale, webhookComment.locale) && Objects.equals(this.mentions, webhookComment.mentions) && Objects.equals(this.domain, webhookComment.domain) && - Objects.equals(this.moderationGroupIds, webhookComment.moderationGroupIds); + Objects.equals(this.moderationGroupIds, webhookComment.moderationGroupIds) && + Objects.equals(this.badges, webhookComment.badges)&& + Objects.equals(this.additionalProperties, webhookComment.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, urlId, url, userId, commenterEmail, commenterName, comment, commentHTML, externalId, parentId, date, votes, votesUp, votesDown, verified, verifiedDate, reviewed, avatarSrc, isSpam, aiDeterminedSpam, hasImages, pageNumber, pageNumberOF, pageNumberNF, approved, locale, mentions, domain, moderationGroupIds); + return Objects.hash(id, urlId, url, userId, commenterEmail, commenterName, comment, commentHTML, externalId, parentId, date, votes, votesUp, votesDown, verified, verifiedDate, reviewed, avatarSrc, isSpam, aiDeterminedSpam, hasImages, pageNumber, pageNumberOF, pageNumberNF, approved, locale, mentions, domain, moderationGroupIds, badges, additionalProperties); } @Override @@ -847,6 +926,8 @@ public String toString() { sb.append(" mentions: ").append(toIndentedString(mentions)).append("\n"); sb.append(" domain: ").append(toIndentedString(domain)).append("\n"); sb.append(" moderationGroupIds: ").append(toIndentedString(moderationGroupIds)).append("\n"); + sb.append(" badges: ").append(toIndentedString(badges)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -865,10 +946,10 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("id", "urlId", "url", "userId", "commenterEmail", "commenterName", "comment", "commentHTML", "externalId", "parentId", "date", "votes", "votesUp", "votesDown", "verified", "verifiedDate", "reviewed", "avatarSrc", "isSpam", "aiDeterminedSpam", "hasImages", "pageNumber", "pageNumberOF", "pageNumberNF", "approved", "locale", "mentions", "domain", "moderationGroupIds")); + openapiFields = new HashSet(Arrays.asList("id", "urlId", "url", "userId", "commenterEmail", "commenterName", "comment", "commentHTML", "externalId", "parentId", "date", "votes", "votesUp", "votesDown", "verified", "verifiedDate", "reviewed", "avatarSrc", "isSpam", "aiDeterminedSpam", "hasImages", "pageNumber", "pageNumberOF", "pageNumberNF", "approved", "locale", "mentions", "domain", "moderationGroupIds", "badges")); // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("id", "urlId", "url", "userId", "commenterEmail", "commenterName", "comment", "commentHTML", "externalId", "parentId", "date", "votes", "votesUp", "votesDown", "verified", "verifiedDate", "reviewed", "avatarSrc", "isSpam", "aiDeterminedSpam", "hasImages", "pageNumber", "pageNumberOF", "pageNumberNF", "approved", "locale", "mentions", "domain", "moderationGroupIds")); + openapiRequiredFields = new HashSet(Arrays.asList("id", "urlId", "url", "userId", "commenterEmail", "commenterName", "comment", "commentHTML", "externalId", "parentId", "date", "votes", "votesUp", "votesDown", "verified", "verifiedDate", "reviewed", "avatarSrc", "isSpam", "aiDeterminedSpam", "hasImages", "pageNumber", "pageNumberOF", "pageNumberNF", "approved", "locale", "mentions", "domain", "moderationGroupIds", "badges")); } /** @@ -884,14 +965,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!WebhookComment.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` in the JSON string is not defined in the `WebhookComment` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : WebhookComment.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -960,6 +1033,16 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } else if (!jsonObj.get("moderationGroupIds").isJsonArray()) { throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `moderationGroupIds` to be an array in the JSON string but got `%s`", jsonObj.get("moderationGroupIds").toString())); } + if (jsonObj.get("badges") != null) { + if (!jsonObj.get("badges").isJsonArray()) { + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "Expected the field `badges` to be an array in the JSON string but got `%s`", jsonObj.get("badges").toString())); + } + JsonArray jsonArraybadges = jsonObj.getAsJsonArray("badges"); + // validate the required field `badges` (array) + for (int i = 0; i < jsonArraybadges.size(); i++) { + CommentUserBadgeInfo.validateJsonElement(jsonArraybadges.get(i)); + } + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -977,6 +1060,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, WebhookComment value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -984,7 +1089,28 @@ public void write(JsonWriter out, WebhookComment value) throws IOException { public WebhookComment read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WebhookComment instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; } }.nullSafe(); diff --git a/client/src/test/java/com/fastcomments/model/CustomConfigParametersTest.java b/client/src/test/java/com/fastcomments/model/CustomConfigParametersTest.java index 07384724..d2dd3304 100644 --- a/client/src/test/java/com/fastcomments/model/CustomConfigParametersTest.java +++ b/client/src/test/java/com/fastcomments/model/CustomConfigParametersTest.java @@ -109,6 +109,14 @@ public void allowedLanguagesTest() { // TODO: test allowedLanguages } + /** + * Test the property 'allowSimpleSSOAdmins' + */ + @Test + public void allowSimpleSSOAdminsTest() { + // TODO: test allowSimpleSSOAdmins + } + /** * Test the property 'autoGenerateUsername' */ @@ -117,6 +125,14 @@ public void autoGenerateUsernameTest() { // TODO: test autoGenerateUsername } + /** + * Test the property 'autoVerifySimpleSSOComments' + */ + @Test + public void autoVerifySimpleSSOCommentsTest() { + // TODO: test autoVerifySimpleSSOComments + } + /** * Test the property 'collapseReplies' */ diff --git a/client/src/test/java/com/fastcomments/model/TenantPackageTest.java b/client/src/test/java/com/fastcomments/model/TenantPackageTest.java index fc169e01..fafacd9f 100644 --- a/client/src/test/java/com/fastcomments/model/TenantPackageTest.java +++ b/client/src/test/java/com/fastcomments/model/TenantPackageTest.java @@ -96,6 +96,30 @@ public void yearlyCostUSDTest() { // TODO: test yearlyCostUSD } + /** + * Test the property 'pricingCurrency' + */ + @Test + public void pricingCurrencyTest() { + // TODO: test pricingCurrency + } + + /** + * Test the property 'monthlyCostLocal' + */ + @Test + public void monthlyCostLocalTest() { + // TODO: test monthlyCostLocal + } + + /** + * Test the property 'yearlyCostLocal' + */ + @Test + public void yearlyCostLocalTest() { + // TODO: test yearlyCostLocal + } + /** * Test the property 'monthlyStripePlanId' */ diff --git a/client/src/test/java/com/fastcomments/model/WebhookCommentTest.java b/client/src/test/java/com/fastcomments/model/WebhookCommentTest.java index aec5f3d0..ead1c097 100644 --- a/client/src/test/java/com/fastcomments/model/WebhookCommentTest.java +++ b/client/src/test/java/com/fastcomments/model/WebhookCommentTest.java @@ -13,6 +13,7 @@ package com.fastcomments.model; +import com.fastcomments.model.CommentUserBadgeInfo; import com.fastcomments.model.CommentUserMentionInfo; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; @@ -272,4 +273,12 @@ public void moderationGroupIdsTest() { // TODO: test moderationGroupIds } + /** + * Test the property 'badges' + */ + @Test + public void badgesTest() { + // TODO: test badges + } + } diff --git a/config.json b/config.json index 7e2a301c..9a431cfc 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { "groupId": "com.fastcomments", "artifactId": "client", - "artifactVersion": "3.1.1", + "artifactVersion": "3.1.2", "packageName": "com.fastcomments", "apiPackage": "com.fastcomments.api", "modelPackage": "com.fastcomments.model", diff --git a/core/src/test/java/com/fastcomments/UnknownResponseFieldsTest.java b/core/src/test/java/com/fastcomments/UnknownResponseFieldsTest.java new file mode 100644 index 00000000..8c4ee24c --- /dev/null +++ b/core/src/test/java/com/fastcomments/UnknownResponseFieldsTest.java @@ -0,0 +1,27 @@ +package com.fastcomments; + +import com.fastcomments.invoker.JSON; +import com.fastcomments.model.GetCommentsResponseWithPresencePublicComment; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * The server adds response fields over time, and apps stay on old SDK versions, so a field the client doesn't know + * must be ignored, not rejected. + */ +public class UnknownResponseFieldsTest { + + @Test + public void testIgnoresFieldsTheClientDoesNotKnow() { + String body = "{\"status\":\"success\",\"comments\":[],\"user\":null,\"pageNumber\":0," + + "\"aFieldAddedLater\":1," + + "\"customConfig\":{\"pageSize\":30,\"aSettingAddedLater\":true}}"; + + GetCommentsResponseWithPresencePublicComment response = + JSON.deserialize(body, GetCommentsResponseWithPresencePublicComment.class); + + assertEquals("success", response.getStatus()); + assertEquals(30, response.getCustomConfig().getPageSize()); + } +} diff --git a/openapi.json b/openapi.json index fe7924f1..7aed0746 100644 --- a/openapi.json +++ b/openapi.json @@ -50,8 +50,7 @@ "name", "type" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UserSearchSectionResult": { "properties": { @@ -69,8 +68,7 @@ "section", "users" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "SearchUsersSectionedResponse": { "properties": { @@ -213,8 +211,7 @@ "required": [ "actions" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "SSOSecurityLevel": { "enum": [ @@ -296,8 +293,7 @@ "format": "date-time" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "CommentTranslationMode": { "type": "string", @@ -331,10 +327,18 @@ "type": "array", "nullable": true }, + "allowSimpleSSOAdmins": { + "type": "boolean", + "description": "Simple SSO users on this page or domain can be admins and moderators: they keep those flags and pick them up from a matching email." + }, "autoGenerateUsername": { "type": "boolean", "description": "Serve each new visitor a unique generated username as the prefilled defaultUsername." }, + "autoVerifySimpleSSOComments": { + "type": "boolean", + "description": "Comments from Simple SSO users on this page or domain are verified right away, instead of through an emailed link." + }, "collapseReplies": { "type": "boolean" }, @@ -664,8 +668,7 @@ "nullable": true } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "APIError": { "properties": { @@ -701,8 +704,7 @@ "reason", "code" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "Record_string.boolean_": { "properties": {}, @@ -895,8 +897,7 @@ "required": [ "status" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetUserNotificationCountResponse": { "properties": { @@ -912,8 +913,7 @@ "status", "count" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "EnumAsObject_typeofNotificationType_": { "properties": {}, @@ -933,8 +933,7 @@ "type", "count" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "HeaderAccountNotification": { "properties": { @@ -995,8 +994,7 @@ "linkText", "createdAt" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "HeaderState": { "properties": { @@ -1033,8 +1031,7 @@ "notificationCounts", "accountNotifications" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UserNotificationWriteResponse": { "properties": { @@ -1055,8 +1052,7 @@ "matchedCount", "modifiedCount" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "IgnoredResponse": { "properties": { @@ -1075,8 +1071,7 @@ "status", "note" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "MediaAsset": { "properties": { @@ -1097,8 +1092,7 @@ "h", "src" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UploadImageResponse": { "properties": { @@ -1124,8 +1118,7 @@ "required": [ "status" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "SizePreset": { "type": "string", @@ -1337,8 +1330,7 @@ "label", "votes" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PollPrivacy": { "description": "Who may see which voter picked which option. Chosen by the poll's author when they build the poll, so it\nlives on the poll itself rather than in the widget config. Anonymous is the default and is never stored on\nthe poll or sent to the client, so an unset value means Anonymous.", @@ -1388,8 +1380,7 @@ "options", "totalVotes" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "VotePollResponse": { "properties": { @@ -1415,8 +1406,7 @@ "myPollVotes", "voterId" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "VotePollBody": { "properties": { @@ -1427,8 +1417,7 @@ "required": [ "optionId" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PollVoterEntry": { "properties": { @@ -1443,8 +1432,7 @@ "name", "optionLabel" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetPollVoterNamesSuccessResponse": { "properties": { @@ -1481,8 +1469,7 @@ "total", "hasMore" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PageReactUser": { "properties": { @@ -1699,8 +1686,7 @@ "description": "Set by the `exact=\"...\"` search syntax. The comment text must equal this value exactly\n(case-sensitive, full-string), as opposed to the substring matching of commentTextSearch." } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "BuildModerationFilterResponse": { "properties": { @@ -1715,8 +1701,7 @@ "status", "moderationFilter" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "BuildModerationFilterParams": { "properties": { @@ -1757,8 +1742,7 @@ "status", "count" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ModerationAPIGetCommentIdsResponse": { "properties": { @@ -1827,8 +1811,7 @@ "type", "description" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ModerationAPIComment": { "properties": { @@ -2009,8 +1992,7 @@ "locale", "verified" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ModerationAPIGetCommentsResponse": { "properties": { @@ -2018,7 +2000,6 @@ "$ref": "#/components/schemas/APIStatus" }, "translations": { - "additionalProperties": false, "type": "object" }, "comments": { @@ -2036,8 +2017,7 @@ "translations", "comments" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ModerationExportResponse": { "properties": { @@ -2052,8 +2032,7 @@ "status", "batchJobId" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ModerationExportStatusResponse": { "properties": { @@ -2076,8 +2055,7 @@ "jobStatus", "recordCount" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ModerationUserSearchProjected": { "properties": { @@ -2100,8 +2078,7 @@ "_id", "username" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ModerationUserSearchResponse": { "properties": { @@ -2143,8 +2120,7 @@ "title", "commentCount" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ModerationPageSearchResponse": { "properties": { @@ -2177,8 +2153,7 @@ "required": [ "domain" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ModerationSiteSearchResponse": { "properties": { @@ -2238,8 +2213,7 @@ "required": [ "status" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PreBanSummary": { "properties": { @@ -2262,8 +2236,7 @@ "usernames", "count" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "BulkPreBanSummary": { "properties": { @@ -2307,8 +2280,7 @@ "userIds", "ipHashes" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "BulkPreBanParams": { "properties": { @@ -2322,8 +2294,7 @@ "required": [ "commentIds" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIBannedUser": { "properties": { @@ -2384,8 +2355,7 @@ "bannedUntil", "hasEmailWildcard" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIBanUserChangedValues": { "properties": { @@ -2436,8 +2406,7 @@ "type": "string" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "APIBanUserChangeLog": { "properties": { @@ -2457,8 +2426,7 @@ "$ref": "#/components/schemas/APIBanUserChangedValues" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "BanUserFromCommentResult": { "properties": { @@ -2478,8 +2446,7 @@ "required": [ "status" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "BannedUserMatchType": { "type": "string", @@ -2512,8 +2479,7 @@ "matchedOn", "matchedOnValue" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APICommentCommonBannedUser": { "properties": { @@ -2553,8 +2519,7 @@ "bannedUntil", "hasEmailWildcard" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIBannedUserWithMultiMatchInfo": { "allOf": [ @@ -2622,8 +2587,7 @@ "required": [ "changelog" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "DeleteCommentAction": { "type": "string", @@ -2661,8 +2625,7 @@ "status", "action" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "SetCommentApprovedResponse": { "properties": { @@ -2699,8 +2662,7 @@ "actionName", "messageHTML" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ModerationAPIGetLogsResponse": { "properties": { @@ -2765,8 +2727,7 @@ "required": [ "ids" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetCommentTextResponse": { "properties": { @@ -2807,8 +2768,7 @@ "required": [ "comment" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "AdjustVotesResponse": { "properties": { @@ -2824,8 +2784,7 @@ "status", "newCommentVotes" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "AdjustCommentVotesParams": { "properties": { @@ -2837,8 +2796,7 @@ "required": [ "adjustVoteAmount" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "VoteResponseUser": { "properties": { @@ -2847,8 +2805,7 @@ "nullable": true } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "VoteResponse": { "properties": { @@ -2881,8 +2838,7 @@ "required": [ "status" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "VoteDeleteResponse": { "properties": { @@ -2896,8 +2852,7 @@ "required": [ "status" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetCommentBanStatusResponse": { "properties": { @@ -2918,8 +2873,7 @@ "emailDomain", "canIPBan" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIModerateUserBanPreferences": { "properties": { @@ -2942,8 +2896,7 @@ "lastBanType", "lastBanDuration" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIModerateGetUserBanPreferencesResponse": { "properties": { @@ -3063,8 +3016,7 @@ "isAwaitingReprocess", "isAwaitingDeletion" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetTenantManualBadgesResponse": { "properties": { @@ -3170,8 +3122,7 @@ "displayedOnComments", "receivedAt" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetUserManualBadgesResponse": { "properties": { @@ -3436,8 +3387,7 @@ "h", "src" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "FeedPostMediaItem": { "properties": { @@ -3457,8 +3407,7 @@ "required": [ "sizes" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "FeedPostLink": { "properties": { @@ -3475,8 +3424,7 @@ "type": "string" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "Int32Map": { "properties": {}, @@ -3557,8 +3505,7 @@ "tenantId", "createdAt" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UserSessionInfo": { "properties": { @@ -3614,8 +3561,7 @@ "type": "string" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "GetPublicFeedPostsResponse": { "properties": { @@ -3641,8 +3587,7 @@ "status", "feedPosts" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "TenantIdWS": { "type": "string" @@ -3710,8 +3655,7 @@ "reactType", "isUndo" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ReactBodyParams": { "properties": { @@ -3719,8 +3663,7 @@ "type": "string" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "UserReactsResponse": { "properties": { @@ -3743,8 +3686,7 @@ "status", "reacts" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateFeedPostResponse": { "properties": { @@ -3759,8 +3701,7 @@ "status", "feedPost" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateFeedPostParams": { "properties": { @@ -3798,8 +3739,7 @@ "$ref": "#/components/schemas/Record_string.string_" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "UpdateFeedPostParams": { "properties": { @@ -3831,8 +3771,7 @@ "$ref": "#/components/schemas/Record_string.string_" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "FeedPostStats": { "properties": { @@ -3844,8 +3783,7 @@ "format": "int32" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "FeedPostsStatsResponse": { "properties": { @@ -3864,8 +3802,7 @@ "status", "stats" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "EventLogEntry": { "properties": { @@ -3901,8 +3838,7 @@ "broadcastId", "data" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetEventLogResponse": { "properties": { @@ -4062,8 +3998,7 @@ "type", "optedOut" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PubSubVote": { "properties": { @@ -4109,8 +4044,7 @@ "createdAt", "verificationId" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "FDomain": { "type": "string" @@ -4302,8 +4236,7 @@ "approved", "locale" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PubSubComment": { "allOf": [ @@ -4433,7 +4366,6 @@ "type": "object" }, "config": { - "additionalProperties": false, "type": "object" }, "isClosed": { @@ -4462,8 +4394,7 @@ "required": [ "type" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PublicAPIGetCommentTextResponse": { "properties": { @@ -4497,8 +4428,7 @@ "approved", "commentHTML" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PublicAPISetCommentTextResponse": { "properties": { @@ -4541,8 +4471,7 @@ "id", "tag" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CommentUserHashTagInfo": { "properties": { @@ -4565,8 +4494,7 @@ "tag", "url" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CommentTextUpdateRequest": { "properties": { @@ -4589,8 +4517,7 @@ "required": [ "comment" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "Pick_GetCommentsResponse.Exclude_keyofGetCommentsResponse.lastGenDate-or-pageNumber__": { "properties": {}, @@ -4813,8 +4740,7 @@ "date", "verified" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "Record_string.any_": { "properties": {}, @@ -4934,8 +4860,7 @@ "user", "pageNumber" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetCommentsResponseWithPresence_PublicComment_": { "allOf": [ @@ -4972,8 +4897,7 @@ "comment", "user" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "SaveCommentsResponseWithPresence": { "allOf": [ @@ -5042,8 +4966,7 @@ "question", "options" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CommentData": { "properties": { @@ -5113,7 +5036,6 @@ "type": "string" }, "meta": { - "additionalProperties": false, "type": "object" }, "moderationGroupIds": { @@ -5158,8 +5080,7 @@ "url", "urlId" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "DeletedCommentResultComment": { "properties": { @@ -5181,8 +5102,7 @@ "commentHTML", "commenterName" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PublicAPIDeleteCommentResponse": { "properties": { @@ -5245,8 +5165,7 @@ "voteDir", "url" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetCommentVoteUserNamesSuccessResponse": { "properties": { @@ -5268,8 +5187,7 @@ "voteUserNames", "hasMore" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CommentTranslationPublic": { "properties": { @@ -5284,8 +5202,7 @@ "commentHTML", "sourceLanguage" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "Record_string.CommentTranslationPublic-or-null_": { "properties": {}, @@ -5326,8 +5243,7 @@ "translations", "failed" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CommentTranslationsRequest": { "properties": { @@ -5341,8 +5257,7 @@ "required": [ "commentIds" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ChangeCommentPinStatusResponse": { "properties": { @@ -5372,8 +5287,7 @@ "status", "commentStatuses" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PublicBlockFromCommentParams": { "properties": { @@ -5389,8 +5303,7 @@ "required": [ "commentIds" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UnblockSuccess": { "properties": { @@ -5405,8 +5318,7 @@ "status", "commentStatuses" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIUserSubscription": { "properties": { @@ -5642,8 +5554,7 @@ "displayLabel", "displayName" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetSSOUserByIdAPIResponse": { "properties": { @@ -6158,8 +6069,7 @@ "to", "type" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "MigrateAPIPagesData": { "properties": { @@ -6324,8 +6234,7 @@ "enabled", "createdAt" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetWebhooksResponse": { "properties": { @@ -6343,8 +6252,7 @@ "status", "webhooks" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "WebhookComment": { "properties": { @@ -6458,6 +6366,12 @@ "type": "string" }, "type": "array" + }, + "badges": { + "items": { + "$ref": "#/components/schemas/CommentUserBadgeInfo" + }, + "type": "array" } }, "required": [ @@ -6489,10 +6403,10 @@ "locale", "mentions", "domain", - "moderationGroupIds" + "moderationGroupIds", + "badges" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetWebhookSamplePayloadsResponse": { "properties": { @@ -6510,8 +6424,7 @@ "status", "payloads" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateWebhookResponse": { "properties": { @@ -6526,8 +6439,7 @@ "status", "webhook" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateWebhookParams": { "properties": { @@ -6551,8 +6463,7 @@ "url", "event" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PublicVote": { "properties": { @@ -6584,8 +6495,7 @@ "direction", "createdAt" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetVotesResponse": { "properties": { @@ -6617,8 +6527,7 @@ "appliedAnonymousVotes", "pendingVotes" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetVotesForUserResponse": { "properties": { @@ -6650,8 +6559,7 @@ "appliedAnonymousVotes", "pendingVotes" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "DigestEmailFrequency": { "enum": [ @@ -6892,8 +6800,7 @@ "loginId", "loginIdDate" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetUserResponse": { "properties": { @@ -6908,8 +6815,7 @@ "status", "user" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIGetUserBadgeResponse": { "properties": { @@ -6924,8 +6830,7 @@ "status", "userBadge" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIGetUserBadgesResponse": { "properties": { @@ -6943,8 +6848,7 @@ "status", "userBadges" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APICreateUserBadgeResponse": { "properties": { @@ -6965,8 +6869,7 @@ "status", "userBadge" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateUserBadgeParams": { "properties": { @@ -6984,8 +6887,7 @@ "userId", "badgeId" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIEmptySuccessResponse": { "properties": { @@ -6996,8 +6898,7 @@ "required": [ "status" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UpdateUserBadgeParams": { "properties": { @@ -7005,8 +6906,7 @@ "type": "boolean" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "UserBadgeProgress": { "properties": { @@ -7050,8 +6950,7 @@ "firstCommentDate", "progress" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIGetUserBadgeProgressResponse": { "properties": { @@ -7066,8 +6965,7 @@ "status", "userBadgeProgress" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIGetUserBadgeProgressListResponse": { "properties": { @@ -7085,8 +6983,7 @@ "status", "userBadgeProgresses" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APITicket": { "properties": { @@ -7134,8 +7031,7 @@ "state", "fileCount" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetTicketsResponse": { "properties": { @@ -7153,8 +7049,7 @@ "status", "tickets" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateTicketResponse": { "properties": { @@ -7169,8 +7064,7 @@ "status", "ticket" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateTicketBody": { "properties": { @@ -7181,8 +7075,7 @@ "required": [ "subject" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APITicketFile": { "properties": { @@ -7229,8 +7122,7 @@ "url", "expiresAt" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APITicketDetail": { "properties": { @@ -7297,8 +7189,7 @@ "fileCount", "files" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetTicketResponse": { "properties": { @@ -7321,8 +7212,7 @@ "ticket", "availableStates" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ChangeTicketStateResponse": { "properties": { @@ -7337,8 +7227,7 @@ "status", "ticket" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ChangeTicketStateBody": { "properties": { @@ -7350,8 +7239,7 @@ "required": [ "state" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ImportedSiteType": { "enum": [ @@ -7425,8 +7313,7 @@ "domain", "createdAt" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "BillingInfo": { "properties": { @@ -7471,8 +7358,7 @@ "zip", "country" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APITenant": { "properties": { @@ -7587,8 +7473,7 @@ "enableProfanityFilter", "enableSpamFilter" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetTenantResponse": { "properties": { @@ -7603,8 +7488,7 @@ "status", "tenant" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetTenantsResponse": { "properties": { @@ -7622,8 +7506,7 @@ "status", "tenants" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateTenantResponse": { "properties": { @@ -7638,8 +7521,7 @@ "status", "tenant" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateTenantBody": { "properties": { @@ -7721,8 +7603,7 @@ "name", "domainConfiguration" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UpdateTenantBody": { "properties": { @@ -7803,8 +7684,7 @@ "type": "string" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "GetTenantUserResponse": { "properties": { @@ -7819,8 +7699,7 @@ "status", "tenantUser" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetTenantUsersResponse": { "properties": { @@ -7838,8 +7717,7 @@ "status", "tenantUsers" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateTenantUserResponse": { "properties": { @@ -7854,8 +7732,7 @@ "status", "tenantUser" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateTenantUserBody": { "properties": { @@ -7942,8 +7819,7 @@ "username", "email" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ReplaceTenantUserBody": { "properties": { @@ -8044,8 +7920,7 @@ "username", "email" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UpdateTenantUserBody": { "properties": { @@ -8128,8 +8003,7 @@ "type": "string" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "TenantPackage": { "properties": { @@ -8152,13 +8026,28 @@ "monthlyCostUSD": { "type": "number", "format": "double", - "nullable": true + "nullable": true, + "description": "Always the USD list price, also on regionally priced tenants (commissions and plan comparisons read it)." }, "yearlyCostUSD": { "type": "number", "format": "double", "nullable": true }, + "pricingCurrency": { + "type": "string", + "description": "Regional prices the tenant is charged, when pricingCurrency is set; the Stripe plan ids below are then in that currency." + }, + "monthlyCostLocal": { + "type": "number", + "format": "double", + "nullable": true + }, + "yearlyCostLocal": { + "type": "number", + "format": "double", + "nullable": true + }, "monthlyStripePlanId": { "type": "string", "nullable": true @@ -8401,8 +8290,7 @@ "hasAuditing", "hasFlexPricing" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetTenantPackageResponse": { "properties": { @@ -8417,8 +8305,7 @@ "status", "tenantPackage" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetTenantPackagesResponse": { "properties": { @@ -8436,8 +8323,7 @@ "status", "tenantPackages" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateTenantPackageResponse": { "properties": { @@ -8452,8 +8338,7 @@ "status", "tenantPackage" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateTenantPackageBody": { "properties": { @@ -8665,8 +8550,7 @@ "featureTaglines", "hasFlexPricing" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "ReplaceTenantPackageBody": { "properties": { @@ -8810,8 +8694,7 @@ "featureTaglines", "hasFlexPricing" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UpdateTenantPackageBody": { "properties": { @@ -8941,8 +8824,7 @@ "format": "double" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "APITenantDailyUsage": { "properties": { @@ -9040,8 +8922,7 @@ "ignored", "apiErrorCount" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetTenantDailyUsagesResponse": { "properties": { @@ -9059,8 +8940,7 @@ "status", "tenantDailyUsages" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "MetaItem": { "properties": { @@ -9078,8 +8958,7 @@ "name", "values" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "QuestionResult": { "properties": { @@ -9144,8 +9023,7 @@ "questionId", "ipHash" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetQuestionResultResponse": { "properties": { @@ -9160,8 +9038,7 @@ "status", "questionResult" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetQuestionResultsResponse": { "properties": { @@ -9179,8 +9056,7 @@ "status", "questionResults" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateQuestionResultResponse": { "properties": { @@ -9195,8 +9071,7 @@ "status", "questionResult" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateQuestionResultBody": { "properties": { @@ -9306,8 +9181,7 @@ "v", "total" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "Record_string.QuestionDatum_": { "properties": {}, @@ -9345,8 +9219,7 @@ "total", "createdAt" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "AggregateQuestionResultsResponse": { "properties": { @@ -9361,8 +9234,7 @@ "status", "data" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "AggregateTimeBucket": { "type": "string", @@ -9393,8 +9265,7 @@ "status", "data" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "BulkAggregateQuestionItem": { "properties": { @@ -9424,8 +9295,7 @@ "required": [ "aggId" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "BulkAggregateQuestionResultsRequest": { "properties": { @@ -9439,8 +9309,7 @@ "required": [ "aggregations" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CommentTranslation": { "properties": { @@ -9468,8 +9337,7 @@ "model", "createdAt" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "Record_string.CommentTranslation_": { "properties": {}, @@ -9773,8 +9641,7 @@ "type": "boolean" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "CommentLogEntry": { "properties": { @@ -9793,8 +9660,7 @@ "d", "t" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "FComment": { "properties": { @@ -10141,8 +10007,7 @@ "approved", "locale" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "FindCommentsByRangeItem": { "properties": { @@ -10162,8 +10027,7 @@ "comment", "result" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "FindCommentsByRangeResponse": { "properties": { @@ -10182,8 +10046,7 @@ "results", "createdAt" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CombineQuestionResultsWithCommentsResponse": { "properties": { @@ -10198,8 +10061,7 @@ "status", "data" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "QuestionConditionOperator": { "enum": [ @@ -10232,8 +10094,7 @@ "value", "subQuestionId" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "QuestionCondition": { "description": "A rule evaluated against a question's answer. value is the score for nps/slider/star/emoji/scale, 1 or 0 for\nthumbs, and the option index for choice/multi.", @@ -10250,8 +10111,7 @@ "operator", "value" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "QuestionConfig": { "properties": { @@ -10384,8 +10244,7 @@ "alwaysShowSubQuestions", "reportingOrder" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetQuestionConfigResponse": { "properties": { @@ -10400,8 +10259,7 @@ "status", "questionConfig" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetQuestionConfigsResponse": { "properties": { @@ -10419,8 +10277,7 @@ "status", "questionConfigs" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateQuestionConfigResponse": { "properties": { @@ -10435,8 +10292,7 @@ "status", "questionConfig" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateQuestionConfigBody": { "properties": { @@ -10628,8 +10484,7 @@ "status", "poll" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "SavePollResponse": { "properties": { @@ -10644,8 +10499,7 @@ "status", "poll" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CommentPollOptionInput": { "properties": { @@ -10660,8 +10514,7 @@ "required": [ "label" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CommentPollPutInput": { "properties": { @@ -10692,8 +10545,7 @@ "question", "options" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CommentPollPatch": { "properties": { @@ -10734,8 +10586,7 @@ "nullable": true } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "PublicPollVote": { "description": "A single vote cast on a comment's poll.", @@ -10776,8 +10627,7 @@ "optionId", "createdAt" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetPollVotesResponse": { "properties": { @@ -10795,8 +10645,7 @@ "status", "pollVotes" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetPollVoteResponse": { "properties": { @@ -10811,8 +10660,7 @@ "status", "pollVote" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreatePollVoteResponse": { "properties": { @@ -10831,8 +10679,7 @@ "pollVote", "poll" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreatePollVoteBody": { "properties": { @@ -10856,8 +10703,7 @@ "commentId", "optionId" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "DeletePollVoteResponse": { "properties": { @@ -10872,8 +10718,7 @@ "status", "poll" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PendingCommentToSyncOutbound": { "properties": { @@ -10917,7 +10762,6 @@ "type": "string" }, "lastError": { - "additionalProperties": false, "type": "object" }, "webhookId": { @@ -10937,8 +10781,7 @@ "domain", "lastError" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetPendingWebhookEventsResponse": { "properties": { @@ -10956,8 +10799,7 @@ "status", "pendingWebhookEvents" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetPendingWebhookEventCountResponse": { "properties": { @@ -10973,8 +10815,7 @@ "status", "count" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetNotificationsResponse": { "properties": { @@ -10992,8 +10833,7 @@ "status", "notifications" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetNotificationCountResponse": { "properties": { @@ -11009,8 +10849,7 @@ "status", "count" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UpdateNotificationBody": { "properties": { @@ -11048,8 +10887,7 @@ "createdAt", "expireAt" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetCachedNotificationCountResponse": { "properties": { @@ -11064,8 +10902,7 @@ "status", "data" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "Moderator": { "properties": { @@ -11165,8 +11002,7 @@ "createdAt", "moderationGroupIds" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetModeratorResponse": { "properties": { @@ -11181,8 +11017,7 @@ "status", "moderator" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetModeratorsResponse": { "properties": { @@ -11200,8 +11035,7 @@ "status", "moderators" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateModeratorResponse": { "properties": { @@ -11216,8 +11050,7 @@ "status", "moderator" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateModeratorBody": { "properties": { @@ -11318,8 +11151,7 @@ "authType", "scopes" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "TenantHashTag": { "properties": { @@ -11346,8 +11178,7 @@ "tenantId", "tag" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetHashTagsResponse": { "properties": { @@ -11365,8 +11196,7 @@ "status", "hashTags" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateHashTagResponse": { "properties": { @@ -11381,8 +11211,7 @@ "status", "hashTag" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateHashTagBody": { "properties": { @@ -11399,8 +11228,7 @@ "required": [ "tag" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "BulkCreateHashTagsResponse": { "properties": { @@ -11425,8 +11253,7 @@ "status", "results" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "BulkCreateHashTagsBody": { "properties": { @@ -11454,8 +11281,7 @@ "required": [ "tags" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UpdateHashTagResponse": { "properties": { @@ -11470,8 +11296,7 @@ "status", "hashTag" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UpdateHashTagBody": { "properties": { @@ -11485,8 +11310,7 @@ "type": "string" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "GetFeedPostsResponse": { "properties": { @@ -11504,8 +11328,7 @@ "status", "feedPosts" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateFeedPostsResponse": { "properties": { @@ -11520,8 +11343,7 @@ "status", "feedPost" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "Record_string.unknown_": { "properties": {}, @@ -11558,8 +11380,7 @@ "defaultTranslationsByLocale", "defaultEJS" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetEmailTemplateDefinitionsResponse": { "properties": { @@ -11577,8 +11398,7 @@ "status", "definitions" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "EmailTemplateRenderErrorResponse": { "properties": { @@ -11616,8 +11436,7 @@ "createdAt", "lastOccurredAt" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetEmailTemplateRenderErrorsResponse": { "properties": { @@ -11635,8 +11454,7 @@ "status", "renderErrors" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CustomEmailTemplate": { "properties": { @@ -11689,8 +11507,7 @@ "translationOverridesByLocale", "testData" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetEmailTemplateResponse": { "properties": { @@ -11705,8 +11522,7 @@ "status", "emailTemplate" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetEmailTemplatesResponse": { "properties": { @@ -11724,8 +11540,7 @@ "status", "emailTemplates" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateEmailTemplateResponse": { "properties": { @@ -11740,8 +11555,7 @@ "status", "emailTemplate" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateEmailTemplateBody": { "properties": { @@ -11769,8 +11583,7 @@ "displayName", "ejs" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UpdateEmailTemplateBody": { "properties": { @@ -11793,8 +11606,7 @@ "$ref": "#/components/schemas/Record_string.unknown_" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "RenderEmailTemplateResponse": { "properties": { @@ -11809,8 +11621,7 @@ "status", "html" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "RenderEmailTemplateBody": { "properties": { @@ -11831,8 +11642,7 @@ "emailTemplateId", "ejs" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "AddDomainConfigParams": { "properties": { @@ -11861,8 +11671,7 @@ "required": [ "domain" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UpdateDomainConfigParams": { "properties": { @@ -11891,8 +11700,7 @@ "required": [ "domain" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PatchDomainConfigParams": { "properties": { @@ -11918,8 +11726,7 @@ "$ref": "#/components/schemas/Record_string.string_" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "APICommentBase": { "properties": { @@ -12164,8 +11971,7 @@ "urlId", "verified" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIComment": { "allOf": [ @@ -12200,8 +12006,7 @@ "status", "comment" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIGetCommentsResponse": { "properties": { @@ -12219,8 +12024,7 @@ "status", "comments" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "UpdatableCommentParams": { "properties": { @@ -12390,8 +12194,7 @@ "type": "array" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "APISaveCommentResponse": { "properties": { @@ -12418,8 +12221,7 @@ "comment", "user" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateCommentParams": { "properties": { @@ -12489,7 +12291,6 @@ "type": "string" }, "meta": { - "additionalProperties": false, "type": "object" }, "moderationGroupIds": { @@ -12569,8 +12370,7 @@ "urlId", "locale" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "FlagCommentResponse": { "properties": { @@ -12594,8 +12394,7 @@ "required": [ "status" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "BlockFromCommentParams": { "properties": { @@ -12606,8 +12405,7 @@ "type": "array" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "UnBlockFromCommentParams": { "properties": { @@ -12618,8 +12416,7 @@ "type": "array" } }, - "type": "object", - "additionalProperties": false + "type": "object" }, "PageMigrationSuccess": { "properties": { @@ -12647,8 +12444,7 @@ "status", "commentsMigrated" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PageMigrationFailure": { "properties": { @@ -12679,8 +12475,7 @@ "code", "reason" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "PageMigrationUndoCounts": { "properties": { @@ -12705,8 +12500,7 @@ "skipped", "notRestorable" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "APIBatchJob": { "properties": { @@ -12893,8 +12687,7 @@ "resourceName", "crudType" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "GetAuditLogsResponse": { "properties": { @@ -12912,8 +12705,7 @@ "status", "auditLogs" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "SORT_DIR": { "type": "string", @@ -13007,8 +12799,7 @@ "status", "data" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "AggregationAPIError": { "properties": { @@ -13033,8 +12824,7 @@ "reason", "code" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "QueryPredicate": { "properties": { @@ -13071,8 +12861,7 @@ "value", "operator" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "AggregationOpType": { "type": "string", @@ -13110,8 +12899,7 @@ "field", "op" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "AggregationRequest": { "description": "The aggregation request accepts a resource, optional grouping keys, an array of operations, and an optional sort", @@ -13161,8 +12949,7 @@ "resourceName", "operations" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateAgentTenantResponse": { "properties": { @@ -13201,8 +12988,7 @@ "apiBaseUrl", "mcpUrl" ], - "type": "object", - "additionalProperties": false + "type": "object" }, "CreateAgentTenantBody": { "properties": { @@ -13222,8 +13008,7 @@ "description": "Free-form identifier of the agent making the request, e.g. \"claude-code\"." } }, - "type": "object", - "additionalProperties": false + "type": "object" } }, "securitySchemes": { diff --git a/pubsub/README.md b/pubsub/README.md index 4516d8c5..ca7a7445 100644 --- a/pubsub/README.md +++ b/pubsub/README.md @@ -32,7 +32,7 @@ Then add the dependency: com.fastcomments pubsub - 3.1.1 + 3.1.2 ``` @@ -52,7 +52,7 @@ repositories { Then add the dependency: ```groovy -implementation 'com.fastcomments:pubsub:3.1.1' +implementation 'com.fastcomments:pubsub:3.1.2' ``` ## Key Components