let quarkus generate the documentation

This commit is contained in:
Athou
2025-07-28 07:33:58 +02:00
parent 947c1f562f
commit c49c31a44e
49 changed files with 314 additions and 1198 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -45,7 +45,6 @@
"react-redux": "^9.2.0", "react-redux": "^9.2.0",
"react-router-dom": "^7.7.1", "react-router-dom": "^7.7.1",
"react-swipeable": "^7.0.2", "react-swipeable": "^7.0.2",
"redoc": "^2.5.0",
"style-to-object": "^1.0.9", "style-to-object": "^1.0.9",
"throttle-debounce": "^5.0.2", "throttle-debounce": "^5.0.2",
"tinycon": "^0.6.8", "tinycon": "^0.6.8",

View File

@@ -3,7 +3,8 @@ import { I18nProvider } from "@lingui/react"
import { MantineProvider } from "@mantine/core" import { MantineProvider } from "@mantine/core"
import { ModalsProvider } from "@mantine/modals" import { ModalsProvider } from "@mantine/modals"
import { Notifications } from "@mantine/notifications" import { Notifications } from "@mantine/notifications"
import React, { useEffect, useState } from "react" import type React from "react"
import { useEffect, useState } from "react"
import { isSafari } from "react-device-detect" import { isSafari } from "react-device-detect"
import ReactGA from "react-ga4" import ReactGA from "react-ga4"
import { HashRouter, Navigate, Route, Routes, useLocation, useNavigate } from "react-router-dom" import { HashRouter, Navigate, Route, Routes, useLocation, useNavigate } from "react-router-dom"
@@ -72,9 +73,6 @@ function Providers(props: { children: React.ReactNode }) {
) )
} }
// api documentation page is very large, load only on-demand
const ApiDocumentationPage = React.lazy(async () => await import("@/pages/app/ApiDocumentationPage"))
function AppRoutes() { function AppRoutes() {
const sidebarVisible = useAppSelector(state => state.tree.sidebarVisible) const sidebarVisible = useAppSelector(state => state.tree.sidebarVisible)
@@ -85,7 +83,6 @@ function AppRoutes() {
<Route path="login" element={<LoginPage />} /> <Route path="login" element={<LoginPage />} />
<Route path="register" element={<RegistrationPage />} /> <Route path="register" element={<RegistrationPage />} />
<Route path="passwordRecovery" element={<PasswordRecoveryPage />} /> <Route path="passwordRecovery" element={<PasswordRecoveryPage />} />
<Route path="api" element={<ApiDocumentationPage />} />
<Route path="app" element={<Layout header={<Header />} sidebar={<Tree />} sidebarVisible={sidebarVisible} />}> <Route path="app" element={<Layout header={<Header />} sidebar={<Tree />} sidebarVisible={sidebarVisible} />}>
<Route path="category"> <Route path="category">
<Route path=":id" element={<FeedEntriesPage sourceType="category" />} /> <Route path=":id" element={<FeedEntriesPage sourceType="category" />} />

View File

@@ -6,7 +6,9 @@ export const redirectToLogin = createAppAsyncThunk("redirect/login", (_, thunkAp
export const redirectToRegistration = createAppAsyncThunk("redirect/register", (_, thunkApi) => thunkApi.dispatch(redirectTo("/register"))) export const redirectToRegistration = createAppAsyncThunk("redirect/register", (_, thunkApi) => thunkApi.dispatch(redirectTo("/register")))
export const redirectToApiDocumentation = createAppAsyncThunk("redirect/api", (_, thunkApi) => thunkApi.dispatch(redirectTo("/api"))) export const redirectToApiDocumentation = createAppAsyncThunk("redirect/api", () => {
window.location.href = "api-documentation/"
})
export const redirectToSelectedSource = createAppAsyncThunk("redirect/selectedSource", (_, thunkApi) => { export const redirectToSelectedSource = createAppAsyncThunk("redirect/selectedSource", (_, thunkApi) => {
const { source } = thunkApi.getState().entries const { source } = thunkApi.getState().entries

View File

@@ -1,20 +0,0 @@
import { Box } from "@mantine/core"
import { HistoryService, RedocStandalone } from "redoc"
// disable redoc url sync because it causes issues with hashrouter
Object.defineProperty(HistoryService.prototype, "replace", {
value: () => {
// do nothing
},
})
function ApiDocumentationPage() {
return (
// force white background because documentation does not support dark theme
<Box style={{ backgroundColor: "#fff" }}>
<RedocStandalone specUrl="openapi.json" />
</Box>
)
}
export default ApiDocumentationPage

View File

@@ -37,7 +37,8 @@ export default defineConfig(() => ({
"/rest": "http://localhost:8083", "/rest": "http://localhost:8083",
"/next": "http://localhost:8083", "/next": "http://localhost:8083",
"/ws": "ws://localhost:8083", "/ws": "ws://localhost:8083",
"/openapi.json": "http://localhost:8083", "/openapi": "http://localhost:8083",
"/api-documentation": "http://localhost:8083",
"/custom_css.css": "http://localhost:8083", "/custom_css.css": "http://localhost:8083",
"/custom_js.js": "http://localhost:8083", "/custom_js.js": "http://localhost:8083",
"/j_security_check": "http://localhost:8083", "/j_security_check": "http://localhost:8083",

View File

@@ -15,7 +15,6 @@
<quarkus.version>3.24.5</quarkus.version> <quarkus.version>3.24.5</quarkus.version>
<querydsl.version>7.0</querydsl.version> <querydsl.version>7.0</querydsl.version>
<rome.version>2.1.0</rome.version> <rome.version>2.1.0</rome.version>
<swagger.version>2.2.34</swagger.version>
<build.database>h2</build.database> <build.database>h2</build.database>
</properties> </properties>
@@ -292,30 +291,6 @@
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo> <failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-maven-plugin-jakarta</artifactId>
<version>${swagger.version}</version>
<?m2e ignore?>
<configuration>
<outputPath>${project.build.directory}/classes/META-INF/resources</outputPath>
<outputFormat>JSONANDYAML</outputFormat>
<resourcePackages>
<package>com.commafeed.frontend.resource</package>
<package>com.commafeed.frontend.model</package>
<package>com.commafeed.frontend.model.request</package>
</resourcePackages>
<prettyPrint>true</prettyPrint>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>resolve</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
@@ -442,17 +417,16 @@
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-liquibase</artifactId> <artifactId>quarkus-liquibase</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
<dependency> <dependency>
<groupId>io.dropwizard.metrics</groupId> <groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-json</artifactId> <artifactId>metrics-json</artifactId>
<version>4.2.33</version> <version>4.2.33</version>
</dependency> </dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency> <dependency>
<groupId>io.github.openfeign.querydsl</groupId> <groupId>io.github.openfeign.querydsl</groupId>
<artifactId>querydsl-apt</artifactId> <artifactId>querydsl-apt</artifactId>

View File

@@ -10,6 +10,7 @@ import com.codahale.metrics.Timer;
import io.quarkus.runtime.annotations.RegisterForReflection; import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection( @RegisterForReflection(
registerFullHierarchy = true,
targets = { targets = {
// metrics // metrics
MetricRegistry.class, Meter.class, Gauge.class, Counter.class, Timer.class, Histogram.class, MetricRegistry.class, Meter.class, Gauge.class, Counter.class, Timer.class, Histogram.class,

View File

@@ -4,9 +4,9 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.quarkus.runtime.annotations.RegisterForReflection; import io.quarkus.runtime.annotations.RegisterForReflection;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -15,7 +15,7 @@ import lombok.Data;
@RegisterForReflection @RegisterForReflection
public class Category implements Serializable { public class Category implements Serializable {
@Schema(description = "category id", requiredMode = RequiredMode.REQUIRED) @Schema(description = "category id", required = true)
private String id; private String id;
@Schema(description = "parent category id") @Schema(description = "parent category id")
@@ -24,18 +24,18 @@ public class Category implements Serializable {
@Schema(description = "parent category name") @Schema(description = "parent category name")
private String parentName; private String parentName;
@Schema(description = "category id", requiredMode = RequiredMode.REQUIRED) @Schema(description = "category id", required = true)
private String name; private String name;
@Schema(description = "category children categories", requiredMode = RequiredMode.REQUIRED) @Schema(description = "category children categories", required = true)
private List<Category> children = new ArrayList<>(); private List<Category> children = new ArrayList<>();
@Schema(description = "category feeds", requiredMode = RequiredMode.REQUIRED) @Schema(description = "category feeds", required = true)
private List<Subscription> feeds = new ArrayList<>(); private List<Subscription> feeds = new ArrayList<>();
@Schema(description = "whether the category is expanded or collapsed", requiredMode = RequiredMode.REQUIRED) @Schema(description = "whether the category is expanded or collapsed", required = true)
private boolean expanded; private boolean expanded;
@Schema(description = "position of the category in the list", requiredMode = RequiredMode.REQUIRED) @Schema(description = "position of the category in the list", required = true)
private int position; private int position;
} }

View File

@@ -4,9 +4,9 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.quarkus.runtime.annotations.RegisterForReflection; import io.quarkus.runtime.annotations.RegisterForReflection;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -15,22 +15,22 @@ import lombok.Data;
@RegisterForReflection @RegisterForReflection
public class Entries implements Serializable { public class Entries implements Serializable {
@Schema(description = "name of the feed or the category requested", requiredMode = RequiredMode.REQUIRED) @Schema(description = "name of the feed or the category requested", required = true)
private String name; private String name;
@Schema(description = "error or warning message") @Schema(description = "error or warning message")
private String message; private String message;
@Schema(description = "times the server tried to refresh the feed and failed", requiredMode = RequiredMode.REQUIRED) @Schema(description = "times the server tried to refresh the feed and failed", required = true)
private int errorCount; private int errorCount;
@Schema(description = "URL of the website, extracted from the feed, only filled if querying for feed entries, not category entries") @Schema(description = "URL of the website, extracted from the feed, only filled if querying for feed entries, not category entries")
private String feedLink; private String feedLink;
@Schema(description = "list generation timestamp", requiredMode = RequiredMode.REQUIRED) @Schema(description = "list generation timestamp", required = true)
private long timestamp; private long timestamp;
@Schema(description = "if the query has more elements", requiredMode = RequiredMode.REQUIRED) @Schema(description = "if the query has more elements", required = true)
private boolean hasMore; private boolean hasMore;
@Schema(description = "the requested offset") @Schema(description = "the requested offset")
@@ -39,12 +39,12 @@ public class Entries implements Serializable {
@Schema(description = "the requested limit") @Schema(description = "the requested limit")
private int limit; private int limit;
@Schema(description = "list of entries", requiredMode = RequiredMode.REQUIRED) @Schema(description = "list of entries", required = true)
private List<Entry> entries = new ArrayList<>(); private List<Entry> entries = new ArrayList<>();
@Schema( @Schema(
description = "if true, the unread flag was ignored in the request, all entries are returned regardless of their read status", description = "if true, the unread flag was ignored in the request, all entries are returned regardless of their read status",
requiredMode = RequiredMode.REQUIRED) required = true)
private boolean ignoredReadStatus; private boolean ignoredReadStatus;
} }

View File

@@ -7,6 +7,8 @@ import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import com.commafeed.backend.feed.FeedUtils; import com.commafeed.backend.feed.FeedUtils;
import com.commafeed.backend.model.FeedEntry; import com.commafeed.backend.model.FeedEntry;
@@ -20,8 +22,6 @@ import com.rometools.rome.feed.synd.SyndEntry;
import com.rometools.rome.feed.synd.SyndEntryImpl; import com.rometools.rome.feed.synd.SyndEntryImpl;
import io.quarkus.runtime.annotations.RegisterForReflection; import io.quarkus.runtime.annotations.RegisterForReflection;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -30,22 +30,22 @@ import lombok.Data;
@RegisterForReflection @RegisterForReflection
public class Entry implements Serializable { public class Entry implements Serializable {
@Schema(description = "entry id", requiredMode = RequiredMode.REQUIRED) @Schema(description = "entry id", required = true)
private String id; private String id;
@Schema(description = "entry guid", requiredMode = RequiredMode.REQUIRED) @Schema(description = "entry guid", required = true)
private String guid; private String guid;
@Schema(description = "entry title", requiredMode = RequiredMode.REQUIRED) @Schema(description = "entry title", required = true)
private String title; private String title;
@Schema(description = "entry content", requiredMode = RequiredMode.REQUIRED) @Schema(description = "entry content", required = true)
private String content; private String content;
@Schema(description = "comma-separated list of categories") @Schema(description = "comma-separated list of categories")
private String categories; private String categories;
@Schema(description = "whether entry content and title are rtl", requiredMode = RequiredMode.REQUIRED) @Schema(description = "whether entry content and title are rtl", required = true)
private boolean rtl; private boolean rtl;
@Schema(description = "entry author") @Schema(description = "entry author")
@@ -69,40 +69,40 @@ public class Entry implements Serializable {
@Schema(description = "entry media thumbnail height, if any") @Schema(description = "entry media thumbnail height, if any")
private Integer mediaThumbnailHeight; private Integer mediaThumbnailHeight;
@Schema(description = "entry publication date", type = "number", requiredMode = RequiredMode.REQUIRED) @Schema(description = "entry publication date", type = SchemaType.INTEGER, required = true)
private Instant date; private Instant date;
@Schema(description = "entry insertion date in the database", type = "number", requiredMode = RequiredMode.REQUIRED) @Schema(description = "entry insertion date in the database", type = SchemaType.INTEGER, required = true)
private Instant insertedDate; private Instant insertedDate;
@Schema(description = "feed id", requiredMode = RequiredMode.REQUIRED) @Schema(description = "feed id", required = true)
private String feedId; private String feedId;
@Schema(description = "feed name", requiredMode = RequiredMode.REQUIRED) @Schema(description = "feed name", required = true)
private String feedName; private String feedName;
@Schema(description = "this entry's feed url", requiredMode = RequiredMode.REQUIRED) @Schema(description = "this entry's feed url", required = true)
private String feedUrl; private String feedUrl;
@Schema(description = "this entry's website url", requiredMode = RequiredMode.REQUIRED) @Schema(description = "this entry's website url", required = true)
private String feedLink; private String feedLink;
@Schema(description = "The favicon url to use for this feed", requiredMode = RequiredMode.REQUIRED) @Schema(description = "The favicon url to use for this feed", required = true)
private String iconUrl; private String iconUrl;
@Schema(description = "entry url", requiredMode = RequiredMode.REQUIRED) @Schema(description = "entry url", required = true)
private String url; private String url;
@Schema(description = "read status", requiredMode = RequiredMode.REQUIRED) @Schema(description = "read status", required = true)
private boolean read; private boolean read;
@Schema(description = "starred status", requiredMode = RequiredMode.REQUIRED) @Schema(description = "starred status", required = true)
private boolean starred; private boolean starred;
@Schema(description = "whether the entry is still markable (old entry statuses are discarded)", requiredMode = RequiredMode.REQUIRED) @Schema(description = "whether the entry is still markable (old entry statuses are discarded)", required = true)
private boolean markable; private boolean markable;
@Schema(description = "tags", requiredMode = RequiredMode.REQUIRED) @Schema(description = "tags", required = true)
private List<String> tags; private List<String> tags;
public static Entry build(FeedEntryStatus status, boolean proxyImages) { public static Entry build(FeedEntryStatus status, boolean proxyImages) {

View File

@@ -2,9 +2,9 @@ package com.commafeed.frontend.model;
import java.io.Serializable; import java.io.Serializable;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.quarkus.runtime.annotations.RegisterForReflection; import io.quarkus.runtime.annotations.RegisterForReflection;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -13,10 +13,10 @@ import lombok.Data;
@RegisterForReflection @RegisterForReflection
public class FeedInfo implements Serializable { public class FeedInfo implements Serializable {
@Schema(description = "url", requiredMode = RequiredMode.REQUIRED) @Schema(description = "url", required = true)
private String url; private String url;
@Schema(description = "title", requiredMode = RequiredMode.REQUIRED) @Schema(description = "title", required = true)
private String title; private String title;
} }

View File

@@ -2,9 +2,9 @@ package com.commafeed.frontend.model;
import java.io.Serializable; import java.io.Serializable;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.quarkus.runtime.annotations.RegisterForReflection; import io.quarkus.runtime.annotations.RegisterForReflection;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -16,34 +16,34 @@ public class ServerInfo implements Serializable {
@Schema @Schema
private String announcement; private String announcement;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private String version; private String version;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private String gitCommit; private String gitCommit;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private boolean allowRegistrations; private boolean allowRegistrations;
@Schema @Schema
private String googleAnalyticsCode; private String googleAnalyticsCode;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private boolean smtpEnabled; private boolean smtpEnabled;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private boolean demoAccountEnabled; private boolean demoAccountEnabled;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private boolean websocketEnabled; private boolean websocketEnabled;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private long websocketPingInterval; private long websocketPingInterval;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private long treeReloadInterval; private long treeReloadInterval;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private long forceRefreshCooldownDuration; private long forceRefreshCooldownDuration;
} }

View File

@@ -2,14 +2,14 @@ package com.commafeed.frontend.model;
import java.io.Serializable; import java.io.Serializable;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import com.commafeed.backend.model.UserSettings.IconDisplayMode; import com.commafeed.backend.model.UserSettings.IconDisplayMode;
import com.commafeed.backend.model.UserSettings.ReadingMode; import com.commafeed.backend.model.UserSettings.ReadingMode;
import com.commafeed.backend.model.UserSettings.ReadingOrder; import com.commafeed.backend.model.UserSettings.ReadingOrder;
import com.commafeed.backend.model.UserSettings.ScrollMode; import com.commafeed.backend.model.UserSettings.ScrollMode;
import io.quarkus.runtime.annotations.RegisterForReflection; import io.quarkus.runtime.annotations.RegisterForReflection;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -18,19 +18,19 @@ import lombok.Data;
@RegisterForReflection @RegisterForReflection
public class Settings implements Serializable { public class Settings implements Serializable {
@Schema(description = "user's preferred language, english if none", requiredMode = RequiredMode.REQUIRED) @Schema(description = "user's preferred language, english if none", required = true)
private String language; private String language;
@Schema(description = "user reads all entries or unread entries only", requiredMode = RequiredMode.REQUIRED) @Schema(description = "user reads all entries or unread entries only", required = true)
private ReadingMode readingMode; private ReadingMode readingMode;
@Schema(description = "user reads entries in ascending or descending order", requiredMode = RequiredMode.REQUIRED) @Schema(description = "user reads entries in ascending or descending order", required = true)
private ReadingOrder readingOrder; private ReadingOrder readingOrder;
@Schema(description = "user wants category and feeds with no unread entries shown", requiredMode = RequiredMode.REQUIRED) @Schema(description = "user wants category and feeds with no unread entries shown", required = true)
private boolean showRead; private boolean showRead;
@Schema(description = "In expanded view, scroll through entries mark them as read", requiredMode = RequiredMode.REQUIRED) @Schema(description = "In expanded view, scroll through entries mark them as read", required = true)
private boolean scrollMarks; private boolean scrollMarks;
@Schema(description = "user's custom css for the website") @Schema(description = "user's custom css for the website")
@@ -39,72 +39,70 @@ public class Settings implements Serializable {
@Schema(description = "user's custom js for the website") @Schema(description = "user's custom js for the website")
private String customJs; private String customJs;
@Schema(description = "user's preferred scroll speed when navigating between entries", requiredMode = RequiredMode.REQUIRED) @Schema(description = "user's preferred scroll speed when navigating between entries", required = true)
private int scrollSpeed; private int scrollSpeed;
@Schema(description = "whether to scroll to the selected entry", requiredMode = RequiredMode.REQUIRED) @Schema(description = "whether to scroll to the selected entry", required = true)
private ScrollMode scrollMode; private ScrollMode scrollMode;
@Schema(description = "number of entries to keep above the selected entry when scrolling", requiredMode = RequiredMode.REQUIRED) @Schema(description = "number of entries to keep above the selected entry when scrolling", required = true)
private int entriesToKeepOnTopWhenScrolling; private int entriesToKeepOnTopWhenScrolling;
@Schema(description = "whether to show the star icon in the header of entries", requiredMode = RequiredMode.REQUIRED) @Schema(description = "whether to show the star icon in the header of entries", required = true)
private IconDisplayMode starIconDisplayMode; private IconDisplayMode starIconDisplayMode;
@Schema(description = "whether to show the external link icon in the header of entries", requiredMode = RequiredMode.REQUIRED) @Schema(description = "whether to show the external link icon in the header of entries", required = true)
private IconDisplayMode externalLinkIconDisplayMode; private IconDisplayMode externalLinkIconDisplayMode;
@Schema(description = "ask for confirmation when marking all entries as read", requiredMode = RequiredMode.REQUIRED) @Schema(description = "ask for confirmation when marking all entries as read", required = true)
private boolean markAllAsReadConfirmation; private boolean markAllAsReadConfirmation;
@Schema( @Schema(description = "navigate to the next unread category or feed after marking all entries as read", required = true)
description = "navigate to the next unread category or feed after marking all entries as read",
requiredMode = RequiredMode.REQUIRED)
private boolean markAllAsReadNavigateToNextUnread; private boolean markAllAsReadNavigateToNextUnread;
@Schema(description = "show commafeed's own context menu on right click", requiredMode = RequiredMode.REQUIRED) @Schema(description = "show commafeed's own context menu on right click", required = true)
private boolean customContextMenu; private boolean customContextMenu;
@Schema(description = "on mobile, show action buttons at the bottom of the screen", requiredMode = RequiredMode.REQUIRED) @Schema(description = "on mobile, show action buttons at the bottom of the screen", required = true)
private boolean mobileFooter; private boolean mobileFooter;
@Schema(description = "show unread count in the title", requiredMode = RequiredMode.REQUIRED) @Schema(description = "show unread count in the title", required = true)
private boolean unreadCountTitle; private boolean unreadCountTitle;
@Schema(description = "show unread count in the favicon", requiredMode = RequiredMode.REQUIRED) @Schema(description = "show unread count in the favicon", required = true)
private boolean unreadCountFavicon; private boolean unreadCountFavicon;
@Schema(description = "primary theme color to use in the UI") @Schema(description = "primary theme color to use in the UI")
private String primaryColor; private String primaryColor;
@Schema(description = "sharing settings", requiredMode = RequiredMode.REQUIRED) @Schema(description = "sharing settings", required = true)
private SharingSettings sharingSettings = new SharingSettings(); private SharingSettings sharingSettings = new SharingSettings();
@Schema(description = "User sharing settings") @Schema(description = "User sharing settings")
@Data @Data
public static class SharingSettings implements Serializable { public static class SharingSettings implements Serializable {
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private boolean email; private boolean email;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private boolean gmail; private boolean gmail;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private boolean facebook; private boolean facebook;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private boolean twitter; private boolean twitter;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private boolean tumblr; private boolean tumblr;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private boolean pocket; private boolean pocket;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private boolean instapaper; private boolean instapaper;
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private boolean buffer; private boolean buffer;
} }
} }

View File

@@ -3,14 +3,15 @@ package com.commafeed.frontend.model;
import java.io.Serializable; import java.io.Serializable;
import java.time.Instant; import java.time.Instant;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import com.commafeed.backend.feed.FeedUtils; import com.commafeed.backend.feed.FeedUtils;
import com.commafeed.backend.model.Feed; import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedCategory; import com.commafeed.backend.model.FeedCategory;
import com.commafeed.backend.model.FeedSubscription; import com.commafeed.backend.model.FeedSubscription;
import io.quarkus.runtime.annotations.RegisterForReflection; import io.quarkus.runtime.annotations.RegisterForReflection;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -19,34 +20,34 @@ import lombok.Data;
@RegisterForReflection @RegisterForReflection
public class Subscription implements Serializable { public class Subscription implements Serializable {
@Schema(description = "subscription id", requiredMode = RequiredMode.REQUIRED) @Schema(description = "subscription id", required = true)
private Long id; private Long id;
@Schema(description = "subscription name", requiredMode = RequiredMode.REQUIRED) @Schema(description = "subscription name", required = true)
private String name; private String name;
@Schema(description = "error message while fetching the feed") @Schema(description = "error message while fetching the feed")
private String message; private String message;
@Schema(description = "error count", requiredMode = RequiredMode.REQUIRED) @Schema(description = "error count", required = true)
private int errorCount; private int errorCount;
@Schema(description = "last time the feed was refreshed", type = "number") @Schema(description = "last time the feed was refreshed", type = SchemaType.INTEGER)
private Instant lastRefresh; private Instant lastRefresh;
@Schema(description = "next time the feed refresh is planned, null if refresh is already queued", type = "number") @Schema(description = "next time the feed refresh is planned, null if refresh is already queued", type = SchemaType.INTEGER)
private Instant nextRefresh; private Instant nextRefresh;
@Schema(description = "this subscription's feed url", requiredMode = RequiredMode.REQUIRED) @Schema(description = "this subscription's feed url", required = true)
private String feedUrl; private String feedUrl;
@Schema(description = "this subscription's website url", requiredMode = RequiredMode.REQUIRED) @Schema(description = "this subscription's website url", required = true)
private String feedLink; private String feedLink;
@Schema(description = "The favicon url to use for this feed", requiredMode = RequiredMode.REQUIRED) @Schema(description = "The favicon url to use for this feed", required = true)
private String iconUrl; private String iconUrl;
@Schema(description = "unread count", requiredMode = RequiredMode.REQUIRED) @Schema(description = "unread count", required = true)
private long unread; private long unread;
@Schema(description = "category id") @Schema(description = "category id")
@@ -55,7 +56,7 @@ public class Subscription implements Serializable {
@Schema(description = "position of the subscription's in the list") @Schema(description = "position of the subscription's in the list")
private int position; private int position;
@Schema(description = "date of the newest item", type = "number") @Schema(description = "date of the newest item", type = SchemaType.INTEGER)
private Instant newestItemTime; private Instant newestItemTime;
@Schema(description = "JEXL string evaluated on new entries to mark them as read if they do not match") @Schema(description = "JEXL string evaluated on new entries to mark them as read if they do not match")

View File

@@ -3,8 +3,10 @@ package com.commafeed.frontend.model;
import java.io.Serializable; import java.io.Serializable;
import java.time.Instant; import java.time.Instant;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.quarkus.runtime.annotations.RegisterForReflection; import io.quarkus.runtime.annotations.RegisterForReflection;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -19,7 +21,7 @@ public class UnreadCount implements Serializable {
@Schema @Schema
private long unreadCount; private long unreadCount;
@Schema(type = "number") @Schema(type = SchemaType.INTEGER)
private Instant newestItemTime; private Instant newestItemTime;
public UnreadCount() { public UnreadCount() {

View File

@@ -3,9 +3,10 @@ package com.commafeed.frontend.model;
import java.io.Serializable; import java.io.Serializable;
import java.time.Instant; import java.time.Instant;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.quarkus.runtime.annotations.RegisterForReflection; import io.quarkus.runtime.annotations.RegisterForReflection;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -14,10 +15,10 @@ import lombok.Data;
@RegisterForReflection @RegisterForReflection
public class UserModel implements Serializable { public class UserModel implements Serializable {
@Schema(description = "user id", requiredMode = RequiredMode.REQUIRED) @Schema(description = "user id", required = true)
private Long id; private Long id;
@Schema(description = "user name", requiredMode = RequiredMode.REQUIRED) @Schema(description = "user name", required = true)
private String name; private String name;
@Schema(description = "user email, if any") @Schema(description = "user email, if any")
@@ -29,19 +30,19 @@ public class UserModel implements Serializable {
@Schema(description = "user password, never returned by the api") @Schema(description = "user password, never returned by the api")
private String password; private String password;
@Schema(description = "account status", requiredMode = RequiredMode.REQUIRED) @Schema(description = "account status", required = true)
private boolean enabled; private boolean enabled;
@Schema(description = "account creation date", type = "number") @Schema(description = "account creation date", type = SchemaType.INTEGER)
private Instant created; private Instant created;
@Schema(description = "last login date", type = "number") @Schema(description = "last login date", type = SchemaType.INTEGER)
private Instant lastLogin; private Instant lastLogin;
@Schema(description = "user is admin", requiredMode = RequiredMode.REQUIRED) @Schema(description = "user is admin", required = true)
private boolean admin; private boolean admin;
@Schema(description = "user last force refresh", type = "number") @Schema(description = "user last force refresh", type = SchemaType.INTEGER)
private Instant lastForceRefresh; private Instant lastForceRefresh;
} }

View File

@@ -5,8 +5,8 @@ import java.io.Serializable;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -14,7 +14,7 @@ import lombok.Data;
@Data @Data
public class AddCategoryRequest implements Serializable { public class AddCategoryRequest implements Serializable {
@Schema(description = "name", requiredMode = RequiredMode.REQUIRED) @Schema(description = "name", required = true)
@NotEmpty @NotEmpty
@Size(max = 128) @Size(max = 128)
private String name; private String name;

View File

@@ -2,8 +2,8 @@ package com.commafeed.frontend.model.request;
import java.io.Serializable; import java.io.Serializable;
import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -14,7 +14,7 @@ public class AdminSaveUserRequest implements Serializable {
@Schema(description = "user id") @Schema(description = "user id")
private Long id; private Long id;
@Schema(description = "user name", requiredMode = RequiredMode.REQUIRED) @Schema(description = "user name", required = true)
private String name; private String name;
@Schema(description = "user email, if any") @Schema(description = "user email, if any")
@@ -23,9 +23,9 @@ public class AdminSaveUserRequest implements Serializable {
@Schema(description = "user password") @Schema(description = "user password")
private String password; private String password;
@Schema(description = "account status", requiredMode = RequiredMode.REQUIRED) @Schema(description = "account status", required = true)
private boolean enabled; private boolean enabled;
@Schema(description = "user is admin", requiredMode = RequiredMode.REQUIRED) @Schema(description = "user is admin", required = true)
private boolean admin; private boolean admin;
} }

View File

@@ -4,8 +4,8 @@ import java.io.Serializable;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -13,7 +13,7 @@ import lombok.Data;
@Data @Data
public class CategoryModificationRequest implements Serializable { public class CategoryModificationRequest implements Serializable {
@Schema(description = "id", requiredMode = RequiredMode.REQUIRED) @Schema(description = "id", required = true)
private Long id; private Long id;
@Schema(description = "new name, null if not changed") @Schema(description = "new name, null if not changed")

View File

@@ -2,8 +2,8 @@ package com.commafeed.frontend.model.request;
import java.io.Serializable; import java.io.Serializable;
import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -11,10 +11,10 @@ import lombok.Data;
@Data @Data
public class CollapseRequest implements Serializable { public class CollapseRequest implements Serializable {
@Schema(description = "category id", requiredMode = RequiredMode.REQUIRED) @Schema(description = "category id", required = true)
private Long id; private Long id;
@Schema(description = "collapse", requiredMode = RequiredMode.REQUIRED) @Schema(description = "collapse", required = true)
private boolean collapse; private boolean collapse;
} }

View File

@@ -5,8 +5,8 @@ import java.io.Serializable;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -14,7 +14,7 @@ import lombok.Data;
@Data @Data
public class FeedInfoRequest implements Serializable { public class FeedInfoRequest implements Serializable {
@Schema(description = "feed url", requiredMode = RequiredMode.REQUIRED) @Schema(description = "feed url", required = true)
@NotEmpty @NotEmpty
@Size(max = 4096) @Size(max = 4096)
private String url; private String url;

View File

@@ -4,8 +4,8 @@ import java.io.Serializable;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -13,7 +13,7 @@ import lombok.Data;
@Data @Data
public class FeedModificationRequest implements Serializable { public class FeedModificationRequest implements Serializable {
@Schema(description = "id", requiredMode = RequiredMode.REQUIRED) @Schema(description = "id", required = true)
private Long id; private Long id;
@Schema(description = "new name, null if not changed") @Schema(description = "new name, null if not changed")

View File

@@ -2,8 +2,8 @@ package com.commafeed.frontend.model.request;
import java.io.Serializable; import java.io.Serializable;
import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -11,7 +11,7 @@ import lombok.Data;
@Data @Data
public class IDRequest implements Serializable { public class IDRequest implements Serializable {
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(required = true)
private Long id; private Long id;
} }

View File

@@ -6,8 +6,8 @@ import java.util.List;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -15,31 +15,26 @@ import lombok.Data;
@Data @Data
public class MarkRequest implements Serializable { public class MarkRequest implements Serializable {
@Schema(description = "entry id, category id, 'all' or 'starred'", requiredMode = RequiredMode.REQUIRED) @Schema(description = "entry id, category id, 'all' or 'starred'", required = true)
@NotEmpty @NotEmpty
@Size(max = 128) @Size(max = 128)
private String id; private String id;
@Schema(description = "mark as read or unread", requiredMode = RequiredMode.REQUIRED) @Schema(description = "mark as read or unread", required = true)
private boolean read; private boolean read;
@Schema(description = "mark only entries older than this", requiredMode = RequiredMode.NOT_REQUIRED) @Schema(description = "mark only entries older than this")
private Long olderThan; private Long olderThan;
@Schema( @Schema(
description = "pass the timestamp you got from the entry list to avoid marking entries that may have been fetched in the mean time and never displayed", description = "pass the timestamp you got from the entry list to avoid marking entries that may have been fetched in the mean time and never displayed")
requiredMode = RequiredMode.NOT_REQUIRED)
private Long insertedBefore; private Long insertedBefore;
@Schema( @Schema(description = "only mark read if a feed has these keywords in the title or rss content")
description = "only mark read if a feed has these keywords in the title or rss content",
requiredMode = RequiredMode.NOT_REQUIRED)
@Size(max = 128) @Size(max = 128)
private String keywords; private String keywords;
@Schema( @Schema(description = "if marking a category or 'all', exclude those subscriptions from the marking")
description = "if marking a category or 'all', exclude those subscriptions from the marking",
requiredMode = RequiredMode.NOT_REQUIRED)
private List<Long> excludedSubscriptions; private List<Long> excludedSubscriptions;
} }

View File

@@ -5,8 +5,8 @@ import java.util.List;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -14,7 +14,7 @@ import lombok.Data;
@Data @Data
public class MultipleMarkRequest implements Serializable { public class MultipleMarkRequest implements Serializable {
@Schema(description = "list of mark requests", requiredMode = RequiredMode.REQUIRED) @Schema(description = "list of mark requests", required = true)
private List<@Valid MarkRequest> requests; private List<@Valid MarkRequest> requests;
} }

View File

@@ -6,8 +6,8 @@ import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -15,7 +15,7 @@ import lombok.Data;
@Schema @Schema
public class PasswordResetRequest implements Serializable { public class PasswordResetRequest implements Serializable {
@Schema(description = "email address for password recovery", requiredMode = RequiredMode.REQUIRED) @Schema(description = "email address for password recovery", required = true)
@Email @Email
@NotEmpty @NotEmpty
@Size(max = 255) @Size(max = 255)

View File

@@ -5,17 +5,17 @@ import java.io.Serializable;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import com.commafeed.security.password.ValidPassword; import com.commafeed.security.password.ValidPassword;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@Schema(description = "Profile modification request") @Schema(description = "Profile modification request")
@Data @Data
public class ProfileModificationRequest implements Serializable { public class ProfileModificationRequest implements Serializable {
@Schema(description = "current user password, required to change profile data", requiredMode = RequiredMode.REQUIRED) @Schema(description = "current user password, required to change profile data", required = true)
@NotEmpty @NotEmpty
@Size(max = 128) @Size(max = 128)
private String currentPassword; private String currentPassword;

View File

@@ -6,10 +6,10 @@ import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import com.commafeed.security.password.ValidPassword; import com.commafeed.security.password.ValidPassword;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -17,17 +17,17 @@ import lombok.Data;
@Schema @Schema
public class RegistrationRequest implements Serializable { public class RegistrationRequest implements Serializable {
@Schema(description = "username, between 3 and 32 characters", requiredMode = RequiredMode.REQUIRED) @Schema(description = "username, between 3 and 32 characters", required = true)
@NotEmpty @NotEmpty
@Size(min = 3, max = 32) @Size(min = 3, max = 32)
private String name; private String name;
@Schema(description = "password, minimum 6 characters", requiredMode = RequiredMode.REQUIRED) @Schema(description = "password, minimum 6 characters", required = true)
@NotEmpty @NotEmpty
@ValidPassword @ValidPassword
private String password; private String password;
@Schema(description = "email address for password recovery", requiredMode = RequiredMode.REQUIRED) @Schema(description = "email address for password recovery", required = true)
@Email @Email
@NotEmpty @NotEmpty
@Size(max = 255) @Size(max = 255)

View File

@@ -5,8 +5,8 @@ import java.io.Serializable;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -14,15 +14,15 @@ import lombok.Data;
@Data @Data
public class StarRequest implements Serializable { public class StarRequest implements Serializable {
@Schema(description = "id", requiredMode = RequiredMode.REQUIRED) @Schema(description = "id", required = true)
@NotEmpty @NotEmpty
@Size(max = 128) @Size(max = 128)
private String id; private String id;
@Schema(description = "feed id", requiredMode = RequiredMode.REQUIRED) @Schema(description = "feed id", required = true)
private Long feedId; private Long feedId;
@Schema(description = "starred or not", requiredMode = RequiredMode.REQUIRED) @Schema(description = "starred or not", required = true)
private boolean starred; private boolean starred;
} }

View File

@@ -5,8 +5,8 @@ import java.io.Serializable;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -14,12 +14,12 @@ import lombok.Data;
@Data @Data
public class SubscribeRequest implements Serializable { public class SubscribeRequest implements Serializable {
@Schema(description = "url of the feed", requiredMode = RequiredMode.REQUIRED) @Schema(description = "url of the feed", required = true)
@NotEmpty @NotEmpty
@Size(max = 4096) @Size(max = 4096)
private String url; private String url;
@Schema(description = "name of the feed for the user", requiredMode = RequiredMode.REQUIRED) @Schema(description = "name of the feed for the user", required = true)
@NotEmpty @NotEmpty
@Size(max = 128) @Size(max = 128)
private String title; private String title;

View File

@@ -3,8 +3,8 @@ package com.commafeed.frontend.model.request;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.microprofile.openapi.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data; import lombok.Data;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -12,10 +12,10 @@ import lombok.Data;
@Data @Data
public class TagRequest implements Serializable { public class TagRequest implements Serializable {
@Schema(description = "entry id", requiredMode = RequiredMode.REQUIRED) @Schema(description = "entry id", required = true)
private Long entryId; private Long entryId;
@Schema(description = "tags", requiredMode = RequiredMode.REQUIRED) @Schema(description = "tags", required = true)
private List<String> tags; private List<String> tags;
} }

View File

@@ -1,6 +1,8 @@
package com.commafeed.frontend.resource; package com.commafeed.frontend.resource;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -18,6 +20,9 @@ import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.Status; import jakarta.ws.rs.core.Response.Status;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.MetricRegistry;
import com.commafeed.CommaFeedConstants; import com.commafeed.CommaFeedConstants;
@@ -36,13 +41,6 @@ import com.commafeed.security.Roles;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@Path("/rest/admin") @Path("/rest/admin")
@@ -120,11 +118,8 @@ public class AdminREST {
@Path("/user/get/{id}") @Path("/user/get/{id}")
@GET @GET
@Transactional @Transactional
@Operation( @Operation(summary = "Get user information", description = "Get user information")
summary = "Get user information", public UserModel adminGetUser(@Parameter(description = "user id", required = true) @PathParam("id") Long id) {
description = "Get user information",
responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = UserModel.class))) })
public Response adminGetUser(@Parameter(description = "user id", required = true) @PathParam("id") Long id) {
Preconditions.checkNotNull(id); Preconditions.checkNotNull(id);
User u = userDAO.findById(id); User u = userDAO.findById(id);
UserModel userModel = new UserModel(); UserModel userModel = new UserModel();
@@ -133,17 +128,14 @@ public class AdminREST {
userModel.setEmail(u.getEmail()); userModel.setEmail(u.getEmail());
userModel.setEnabled(!u.isDisabled()); userModel.setEnabled(!u.isDisabled());
userModel.setAdmin(userRoleDAO.findAll(u).stream().anyMatch(r -> r.getRole() == Role.ADMIN)); userModel.setAdmin(userRoleDAO.findAll(u).stream().anyMatch(r -> r.getRole() == Role.ADMIN));
return Response.ok(userModel).build(); return userModel;
} }
@Path("/user/getAll") @Path("/user/getAll")
@GET @GET
@Transactional @Transactional
@Operation( @Operation(summary = "Get all users", description = "Get all users")
summary = "Get all users", public List<UserModel> adminGetUsers() {
description = "Get all users",
responses = { @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = UserModel.class)))) })
public Response adminGetUsers() {
Map<Long, UserModel> users = new HashMap<>(); Map<Long, UserModel> users = new HashMap<>();
for (UserRole role : userRoleDAO.findAll()) { for (UserRole role : userRoleDAO.findAll()) {
User u = role.getUser(); User u = role.getUser();
@@ -162,7 +154,7 @@ public class AdminREST {
userModel.setAdmin(true); userModel.setAdmin(true);
} }
} }
return Response.ok(users.values()).build(); return new ArrayList<>(users.values());
} }
@Path("/user/delete") @Path("/user/delete")

View File

@@ -28,6 +28,12 @@ import jakarta.ws.rs.core.UriInfo;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.media.Content;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import com.commafeed.CommaFeedConfiguration; import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.dao.FeedCategoryDAO; import com.commafeed.backend.dao.FeedCategoryDAO;
@@ -60,13 +66,6 @@ import com.rometools.rome.feed.synd.SyndFeed;
import com.rometools.rome.feed.synd.SyndFeedImpl; import com.rometools.rome.feed.synd.SyndFeedImpl;
import com.rometools.rome.io.SyndFeedOutput; import com.rometools.rome.io.SyndFeedOutput;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -95,10 +94,11 @@ public class CategoryREST {
@Path("/entries") @Path("/entries")
@GET @GET
@Transactional @Transactional
@Operation( @Operation(summary = "Get category entries", description = "Get a list of category entries")
summary = "Get category entries", @APIResponse(
description = "Get a list of category entries", responseCode = "200",
responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = Entries.class))) }) content = { @Content(mediaType = "application/json", schema = @Schema(implementation = Entries.class)) })
@APIResponse(responseCode = "404", description = "category not found")
public Response getCategoryEntries( public Response getCategoryEntries(
@Parameter(description = "id of the category, 'all' or 'starred'", required = true) @QueryParam("id") String id, @Parameter(description = "id of the category, 'all' or 'starred'", required = true) @QueryParam("id") String id,
@Parameter( @Parameter(
@@ -269,11 +269,8 @@ public class CategoryREST {
@Path("/add") @Path("/add")
@POST @POST
@Transactional @Transactional
@Operation( @Operation(summary = "Add a category", description = "Add a new feed category")
summary = "Add a category", public Long addCategory(@Valid @Parameter(required = true) AddCategoryRequest req) {
description = "Add a new feed category",
responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = Long.class))) })
public Response addCategory(@Valid @Parameter(required = true) AddCategoryRequest req) {
Preconditions.checkNotNull(req); Preconditions.checkNotNull(req);
Preconditions.checkNotNull(req.getName()); Preconditions.checkNotNull(req.getName());
@@ -290,7 +287,7 @@ public class CategoryREST {
cat.setParent(parent); cat.setParent(parent);
} }
feedCategoryDAO.persist(cat); feedCategoryDAO.persist(cat);
return Response.ok(cat.getId()).build(); return cat.getId();
} }
@POST @POST
@@ -390,23 +387,18 @@ public class CategoryREST {
@GET @GET
@Path("/unreadCount") @Path("/unreadCount")
@Transactional @Transactional
@Operation( @Operation(summary = "Get unread count for feed subscriptions")
summary = "Get unread count for feed subscriptions", public List<UnreadCount> getUnreadCount() {
responses = { @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = UnreadCount.class)))) })
public Response getUnreadCount() {
User user = authenticationContext.getCurrentUser(); User user = authenticationContext.getCurrentUser();
Map<Long, UnreadCount> unreadCount = feedSubscriptionService.getUnreadCount(user); Map<Long, UnreadCount> unreadCount = feedSubscriptionService.getUnreadCount(user);
return Response.ok(Lists.newArrayList(unreadCount.values())).build(); return Lists.newArrayList(unreadCount.values());
} }
@GET @GET
@Path("/get") @Path("/get")
@Transactional @Transactional
@Operation( @Operation(summary = "Get root category", description = "Get all categories and subscriptions of the user")
summary = "Get root category", public Category getRootCategory() {
description = "Get all categories and subscriptions of the user",
responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = Category.class))) })
public Response getRootCategory() {
User user = authenticationContext.getCurrentUser(); User user = authenticationContext.getCurrentUser();
List<FeedCategory> categories = feedCategoryDAO.findAll(user); List<FeedCategory> categories = feedCategoryDAO.findAll(user);
@@ -417,7 +409,7 @@ public class CategoryREST {
root.setId("all"); root.setId("all");
root.setName("All"); root.setName("All");
return Response.ok(root).build(); return root;
} }
private Category buildCategory(Long id, List<FeedCategory> categories, List<FeedSubscription> subscriptions, private Category buildCategory(Long id, List<FeedCategory> categories, List<FeedSubscription> subscriptions,

View File

@@ -14,6 +14,10 @@ import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import com.commafeed.backend.dao.FeedEntryTagDAO; import com.commafeed.backend.dao.FeedEntryTagDAO;
import com.commafeed.backend.model.User; import com.commafeed.backend.model.User;
import com.commafeed.backend.service.FeedEntryService; import com.commafeed.backend.service.FeedEntryService;
@@ -26,9 +30,6 @@ import com.commafeed.security.AuthenticationContext;
import com.commafeed.security.Roles; import com.commafeed.security.Roles;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@Path("/rest/entry") @Path("/rest/entry")

View File

@@ -29,6 +29,12 @@ import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.SystemUtils;
import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.HttpStatus;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.media.Content;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.resteasy.reactive.Cache; import org.jboss.resteasy.reactive.Cache;
import org.jboss.resteasy.reactive.RestForm; import org.jboss.resteasy.reactive.RestForm;
@@ -80,12 +86,6 @@ import com.rometools.rome.io.FeedException;
import com.rometools.rome.io.SyndFeedOutput; import com.rometools.rome.io.SyndFeedOutput;
import com.rometools.rome.io.WireFeedOutput; import com.rometools.rome.io.WireFeedOutput;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -131,10 +131,11 @@ public class FeedREST {
@Path("/entries") @Path("/entries")
@GET @GET
@Transactional @Transactional
@Operation( @Operation(summary = "Get feed entries", description = "Get a list of feed entries")
summary = "Get feed entries", @APIResponse(
description = "Get a list of feed entries", responseCode = "200",
responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = Entries.class))) }) content = { @Content(mediaType = "application/json", schema = @Schema(implementation = Entries.class)) })
@APIResponse(responseCode = "404", description = "feed not found")
public Response getFeedEntries(@Parameter(description = "id of the feed", required = true) @QueryParam("id") String id, public Response getFeedEntries(@Parameter(description = "id of the feed", required = true) @QueryParam("id") String id,
@Parameter( @Parameter(
description = "all entries or only unread ones", description = "all entries or only unread ones",
@@ -251,10 +252,11 @@ public class FeedREST {
@POST @POST
@Path("/fetch") @Path("/fetch")
@Transactional @Transactional
@Operation( @Operation(summary = "Fetch a feed", description = "Fetch a feed by its url")
summary = "Fetch a feed", @APIResponse(
description = "Fetch a feed by its url", responseCode = "200",
responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = FeedInfo.class))) }) content = { @Content(mediaType = "application/json", schema = @Schema(implementation = FeedInfo.class)) })
@APIResponse(responseCode = "404", description = "feed not found")
public Response fetchFeed(@Valid @Parameter(description = "feed url", required = true) FeedInfoRequest req) { public Response fetchFeed(@Valid @Parameter(description = "feed url", required = true) FeedInfoRequest req) {
Preconditions.checkNotNull(req); Preconditions.checkNotNull(req);
Preconditions.checkNotNull(req.getUrl()); Preconditions.checkNotNull(req.getUrl());
@@ -309,9 +311,11 @@ public class FeedREST {
@GET @GET
@Path("/get/{id}") @Path("/get/{id}")
@Transactional @Transactional
@Operation( @Operation(summary = "get feed")
summary = "get feed", @APIResponse(
responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = Subscription.class))) }) responseCode = "200",
content = { @Content(mediaType = "application/json", schema = @Schema(implementation = Subscription.class)) })
@APIResponse(responseCode = "404", description = "feed not found")
public Response getFeed(@Parameter(description = "user id", required = true) @PathParam("id") Long id) { public Response getFeed(@Parameter(description = "user id", required = true) @PathParam("id") Long id) {
Preconditions.checkNotNull(id); Preconditions.checkNotNull(id);
@@ -345,10 +349,10 @@ public class FeedREST {
@POST @POST
@Path("/subscribe") @Path("/subscribe")
@Transactional @Transactional
@Operation( @Operation(summary = "Subscribe to a feed", description = "Subscribe to a feed")
summary = "Subscribe to a feed", @APIResponse(
description = "Subscribe to a feed", responseCode = "200",
responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = Long.class))) }) content = { @Content(mediaType = "application/json", schema = @Schema(implementation = Long.class)) })
public Response subscribe(@Valid @Parameter(description = "subscription request", required = true) SubscribeRequest req) { public Response subscribe(@Valid @Parameter(description = "subscription request", required = true) SubscribeRequest req) {
Preconditions.checkNotNull(req); Preconditions.checkNotNull(req);
Preconditions.checkNotNull(req.getTitle()); Preconditions.checkNotNull(req.getTitle());

View File

@@ -1,16 +1,18 @@
package com.commafeed.frontend.resource; package com.commafeed.frontend.resource;
import io.swagger.v3.oas.annotations.OpenAPIDefinition; import jakarta.ws.rs.core.Application;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.info.Info; import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import org.eclipse.microprofile.openapi.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.security.SecurityScheme; import org.eclipse.microprofile.openapi.annotations.info.Info;
import io.swagger.v3.oas.annotations.servers.Server; import org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement;
import org.eclipse.microprofile.openapi.annotations.security.SecurityScheme;
import org.eclipse.microprofile.openapi.annotations.servers.Server;
@OpenAPIDefinition( @OpenAPIDefinition(
info = @Info(title = "CommaFeed API"), info = @Info(title = "CommaFeed API", version = "1.0.0"),
servers = { @Server(description = "CommaFeed API", url = "/") }, servers = { @Server(description = "CommaFeed API", url = "/") },
security = { @SecurityRequirement(name = "basicAuth") }) security = { @SecurityRequirement(name = "basicAuth") })
@SecurityScheme(name = "basicAuth", type = SecuritySchemeType.HTTP, scheme = "basic") @SecurityScheme(securitySchemeName = "basicAuth", type = SecuritySchemeType.HTTP, scheme = "basic")
public class OpenAPI { public class OpenAPI extends Application {
} }

View File

@@ -13,6 +13,10 @@ import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.Status; import jakarta.ws.rs.core.Response.Status;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import com.commafeed.CommaFeedConfiguration; import com.commafeed.CommaFeedConfiguration;
import com.commafeed.CommaFeedVersion; import com.commafeed.CommaFeedVersion;
import com.commafeed.backend.HttpGetter; import com.commafeed.backend.HttpGetter;
@@ -21,12 +25,6 @@ import com.commafeed.backend.feed.ImageProxyUrl;
import com.commafeed.frontend.model.ServerInfo; import com.commafeed.frontend.model.ServerInfo;
import com.commafeed.security.Roles; import com.commafeed.security.Roles;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@Path("/rest/server") @Path("/rest/server")
@@ -46,11 +44,8 @@ public class ServerREST {
@GET @GET
@PermitAll @PermitAll
@Transactional @Transactional
@Operation( @Operation(summary = "Get server infos", description = "Get server infos")
summary = "Get server infos", public ServerInfo getServerInfos() {
description = "Get server infos",
responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = ServerInfo.class))) })
public Response getServerInfos() {
ServerInfo infos = new ServerInfo(); ServerInfo infos = new ServerInfo();
infos.setAnnouncement(config.announcement().orElse(null)); infos.setAnnouncement(config.announcement().orElse(null));
infos.setVersion(version.getVersion()); infos.setVersion(version.getVersion());
@@ -63,7 +58,7 @@ public class ServerREST {
infos.setWebsocketPingInterval(config.websocket().pingInterval().toMillis()); infos.setWebsocketPingInterval(config.websocket().pingInterval().toMillis());
infos.setTreeReloadInterval(config.websocket().treeReloadInterval().toMillis()); infos.setTreeReloadInterval(config.websocket().treeReloadInterval().toMillis());
infos.setForceRefreshCooldownDuration(config.feedRefresh().forceRefreshCooldownDuration().toMillis()); infos.setForceRefreshCooldownDuration(config.feedRefresh().forceRefreshCooldownDuration().toMillis());
return Response.ok(infos).build(); return infos;
} }
@Path("/proxy") @Path("/proxy")

View File

@@ -28,6 +28,9 @@ import jakarta.ws.rs.core.UriInfo;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.hc.core5.net.URIBuilder; import org.apache.hc.core5.net.URIBuilder;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import com.commafeed.CommaFeedConfiguration; import com.commafeed.CommaFeedConfiguration;
import com.commafeed.CommaFeedConstants; import com.commafeed.CommaFeedConstants;
@@ -56,12 +59,6 @@ import com.commafeed.security.AuthenticationContext;
import com.commafeed.security.Roles; import com.commafeed.security.Roles;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -88,11 +85,8 @@ public class UserREST {
@Path("/settings") @Path("/settings")
@GET @GET
@Transactional @Transactional
@Operation( @Operation(summary = "Retrieve user settings", description = "Retrieve user settings")
summary = "Retrieve user settings", public Settings getUserSettings() {
description = "Retrieve user settings",
responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = Settings.class))) })
public Response getUserSettings() {
Settings s = new Settings(); Settings s = new Settings();
User user = authenticationContext.getCurrentUser(); User user = authenticationContext.getCurrentUser();
@@ -155,7 +149,7 @@ public class UserREST {
s.setUnreadCountTitle(false); s.setUnreadCountTitle(false);
s.setUnreadCountFavicon(true); s.setUnreadCountFavicon(true);
} }
return Response.ok(s).build(); return s;
} }
@Path("/settings") @Path("/settings")
@@ -208,10 +202,8 @@ public class UserREST {
@Path("/profile") @Path("/profile")
@GET @GET
@Transactional @Transactional
@Operation( @Operation(summary = "Retrieve user's profile")
summary = "Retrieve user's profile", public UserModel getUserProfile() {
responses = { @ApiResponse(content = @Content(schema = @Schema(implementation = UserModel.class))) })
public Response getUserProfile() {
User user = authenticationContext.getCurrentUser(); User user = authenticationContext.getCurrentUser();
UserModel userModel = new UserModel(); UserModel userModel = new UserModel();
@@ -226,7 +218,7 @@ public class UserREST {
userModel.setAdmin(true); userModel.setAdmin(true);
} }
} }
return Response.ok(userModel).build(); return userModel;
} }
@Path("/profile") @Path("/profile")

View File

@@ -27,6 +27,7 @@ import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.MultivaluedMap; import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.UriInfo; import jakarta.ws.rs.core.UriInfo;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.jboss.resteasy.reactive.server.multipart.FormValue; import org.jboss.resteasy.reactive.server.multipart.FormValue;
import org.jboss.resteasy.reactive.server.multipart.MultipartFormDataInput; import org.jboss.resteasy.reactive.server.multipart.MultipartFormDataInput;
@@ -51,7 +52,6 @@ import com.commafeed.frontend.resource.fever.FeverResponse.FeverFeedGroup;
import com.commafeed.frontend.resource.fever.FeverResponse.FeverGroup; import com.commafeed.frontend.resource.fever.FeverResponse.FeverGroup;
import com.commafeed.frontend.resource.fever.FeverResponse.FeverItem; import com.commafeed.frontend.resource.fever.FeverResponse.FeverItem;
import io.swagger.v3.oas.annotations.Hidden;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
/** /**
@@ -70,7 +70,6 @@ import lombok.RequiredArgsConstructor;
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@RequiredArgsConstructor @RequiredArgsConstructor
@Singleton @Singleton
@Hidden
public class FeverREST { public class FeverREST {
private static final String PATH = "/user/{userId}{optionalTrailingFever : (/fever)?}{optionalTrailingSlash : (/)?}"; private static final String PATH = "/user/{userId}{optionalTrailingFever : (/fever)?}{optionalTrailingSlash : (/)?}";
@@ -91,6 +90,7 @@ public class FeverREST {
@Path(PATH) @Path(PATH)
@POST @POST
@Transactional @Transactional
@Operation(hidden = true)
public FeverResponse formUrlencoded(@Context UriInfo uri, @PathParam("userId") Long userId, MultivaluedMap<String, String> form) { public FeverResponse formUrlencoded(@Context UriInfo uri, @PathParam("userId") Long userId, MultivaluedMap<String, String> form) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
uri.getQueryParameters().forEach((k, v) -> params.put(k, v.get(0))); uri.getQueryParameters().forEach((k, v) -> params.put(k, v.get(0)));
@@ -103,6 +103,7 @@ public class FeverREST {
@Path(PATH) @Path(PATH)
@POST @POST
@Transactional @Transactional
@Operation(hidden = true)
public FeverResponse noForm(@Context UriInfo uri, @PathParam("userId") Long userId) { public FeverResponse noForm(@Context UriInfo uri, @PathParam("userId") Long userId) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
uri.getQueryParameters().forEach((k, v) -> params.put(k, v.get(0))); uri.getQueryParameters().forEach((k, v) -> params.put(k, v.get(0)));
@@ -114,6 +115,7 @@ public class FeverREST {
@Path(PATH) @Path(PATH)
@GET @GET
@Transactional @Transactional
@Operation(hidden = true)
public FeverResponse get(@Context UriInfo uri, @PathParam("userId") Long userId) { public FeverResponse get(@Context UriInfo uri, @PathParam("userId") Long userId) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
uri.getQueryParameters().forEach((k, v) -> params.put(k, v.get(0))); uri.getQueryParameters().forEach((k, v) -> params.put(k, v.get(0)));
@@ -126,6 +128,7 @@ public class FeverREST {
@Path(PATH) @Path(PATH)
@POST @POST
@Transactional @Transactional
@Operation(hidden = true)
public FeverResponse formData(@Context UriInfo uri, @PathParam("userId") Long userId, MultipartFormDataInput form) { public FeverResponse formData(@Context UriInfo uri, @PathParam("userId") Long userId, MultipartFormDataInput form) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
uri.getQueryParameters().forEach((k, v) -> params.put(k, v.get(0))); uri.getQueryParameters().forEach((k, v) -> params.put(k, v.get(0)));

View File

@@ -6,6 +6,8 @@ import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import org.eclipse.microprofile.openapi.annotations.Operation;
import com.commafeed.backend.dao.UserSettingsDAO; import com.commafeed.backend.dao.UserSettingsDAO;
import com.commafeed.backend.model.User; import com.commafeed.backend.model.User;
import com.commafeed.backend.model.UserSettings; import com.commafeed.backend.model.UserSettings;
@@ -24,6 +26,7 @@ public class CustomCssServlet {
@GET @GET
@Transactional @Transactional
@Operation(hidden = true)
public String get() { public String get() {
User user = authenticationContext.getCurrentUser(); User user = authenticationContext.getCurrentUser();
if (user == null) { if (user == null) {

View File

@@ -6,6 +6,8 @@ import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import org.eclipse.microprofile.openapi.annotations.Operation;
import com.commafeed.backend.dao.UserSettingsDAO; import com.commafeed.backend.dao.UserSettingsDAO;
import com.commafeed.backend.model.User; import com.commafeed.backend.model.User;
import com.commafeed.backend.model.UserSettings; import com.commafeed.backend.model.UserSettings;
@@ -24,6 +26,7 @@ public class CustomJsServlet {
@GET @GET
@Transactional @Transactional
@Operation(hidden = true)
public String get() { public String get() {
User user = authenticationContext.getCurrentUser(); User user = authenticationContext.getCurrentUser();
if (user == null) { if (user == null) {

View File

@@ -12,6 +12,7 @@ import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo; import jakarta.ws.rs.core.UriInfo;
import org.eclipse.microprofile.config.inject.ConfigProperty; import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.openapi.annotations.Operation;
@Path("/logout") @Path("/logout")
@PermitAll @PermitAll
@@ -27,6 +28,7 @@ public class LogoutServlet {
} }
@GET @GET
@Operation(hidden = true)
public Response get() { public Response get() {
NewCookie removeCookie = new NewCookie.Builder(cookieName).maxAge(0).expiry(Date.from(Instant.EPOCH)).path("/").build(); NewCookie removeCookie = new NewCookie.Builder(cookieName).maxAge(0).expiry(Date.from(Instant.EPOCH)).path("/").build();
return Response.temporaryRedirect(uri.getBaseUri()).cookie(removeCookie).build(); return Response.temporaryRedirect(uri.getBaseUri()).cookie(removeCookie).build();

View File

@@ -13,6 +13,7 @@ import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo; import jakarta.ws.rs.core.UriInfo;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.eclipse.microprofile.openapi.annotations.Operation;
import com.commafeed.backend.dao.FeedCategoryDAO; import com.commafeed.backend.dao.FeedCategoryDAO;
import com.commafeed.backend.dao.FeedEntryStatusDAO; import com.commafeed.backend.dao.FeedEntryStatusDAO;
@@ -42,6 +43,7 @@ public class NextUnreadServlet {
@GET @GET
@Transactional @Transactional
@Operation(hidden = true)
public Response get(@QueryParam("category") String categoryId, @QueryParam("order") @DefaultValue("desc") ReadingOrder order) { public Response get(@QueryParam("category") String categoryId, @QueryParam("order") @DefaultValue("desc") ReadingOrder order) {
User user = authenticationContext.getCurrentUser(); User user = authenticationContext.getCurrentUser();
if (user == null) { if (user == null) {

View File

@@ -9,6 +9,7 @@ import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.HttpStatus;
import org.eclipse.microprofile.openapi.annotations.Operation;
import com.commafeed.CommaFeedConfiguration; import com.commafeed.CommaFeedConfiguration;
@@ -24,6 +25,7 @@ public class RobotsTxtDisallowAllServlet {
private final CommaFeedConfiguration config; private final CommaFeedConfiguration config;
@GET @GET
@Operation(hidden = true)
public Response get() { public Response get() {
if (config.hideFromWebCrawlers()) { if (config.hideFromWebCrawlers()) {
return Response.ok("User-agent: *\nDisallow: /").build(); return Response.ok("User-agent: *\nDisallow: /").build();

View File

@@ -10,7 +10,7 @@ quarkus.http.filter.index-html.header."Cache-Control"=no-cache
quarkus.http.filter.index-html.matches=/ quarkus.http.filter.index-html.matches=/
## make sure the openapi documentation is always up to date ## make sure the openapi documentation is always up to date
quarkus.http.filter.openapi.header."Cache-Control"=no-cache quarkus.http.filter.openapi.header."Cache-Control"=no-cache
quarkus.http.filter.openapi.matches=/openapi[.](json|yaml) quarkus.http.filter.openapi.matches=/openapi
## make sure /next always redirects to the next unread entry ## make sure /next always redirects to the next unread entry
quarkus.http.filter.next.header."Cache-Control"=no-cache quarkus.http.filter.next.header."Cache-Control"=no-cache
quarkus.http.filter.next.matches=/next quarkus.http.filter.next.matches=/next
@@ -32,6 +32,11 @@ quarkus.websocket.dispatch-to-worker=true
quarkus.liquibase.change-log=migrations.xml quarkus.liquibase.change-log=migrations.xml
quarkus.liquibase.migrate-at-start=true quarkus.liquibase.migrate-at-start=true
# openapi
quarkus.smallrye-openapi.path=/openapi
quarkus.swagger-ui.path=/api-documentation
quarkus.swagger-ui.always-include=true
# shutdown # shutdown
quarkus.shutdown.timeout=5s quarkus.shutdown.timeout=5s

View File

@@ -20,8 +20,8 @@ class DocumentationIT {
@Test @Test
void documentationAvailable() { void documentationAvailable() {
Page page = context.newPage(); Page page = context.newPage();
page.navigate("http://localhost:8085/#/api"); page.navigate("http://localhost:8085/api-documentation");
PlaywrightAssertions.assertThat(page.getByText("Download OpenAPI specification:")).isVisible(); PlaywrightAssertions.assertThat(page.getByText("CommaFeed API 1.0.0 OAS")).isVisible();
} }
} }

View File

@@ -12,7 +12,7 @@ import io.restassured.RestAssured;
class CompressionIT { class CompressionIT {
@ParameterizedTest @ParameterizedTest
@ValueSource(strings = { "/rest/server/get", "/openapi.json" }) @ValueSource(strings = { "/rest/server/get", "/" })
void servedWithCompression(String path) { void servedWithCompression(String path) {
RestAssured.given().when().get(path).then().statusCode(200).header(HttpHeaders.CONTENT_ENCODING, "gzip"); RestAssured.given().when().get(path).then().statusCode(200).header(HttpHeaders.CONTENT_ENCODING, "gzip");
} }

View File

@@ -10,7 +10,7 @@ import io.restassured.RestAssured;
class StaticFilesIT { class StaticFilesIT {
@ParameterizedTest @ParameterizedTest
@ValueSource(strings = { "/", "/openapi.json", "/openapi.yaml" }) @ValueSource(strings = { "/", "/openapi" })
void servedWithoutCache(String path) { void servedWithoutCache(String path) {
RestAssured.given().when().get(path).then().statusCode(200).header("Cache-Control", "no-cache"); RestAssured.given().when().get(path).then().statusCode(200).header("Cache-Control", "no-cache");
} }