Skip to content

Commit

Permalink
Merge pull request #3731 from nscuro/openapi-v3
Browse files Browse the repository at this point in the history
Fix OpenAPI types of UNIX timestamp fields
  • Loading branch information
nscuro committed May 18, 2024
2 parents 7573f39 + a7119e8 commit 2980188
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import org.dependencytrack.model.Vulnerability.Source;

import javax.jdo.annotations.Column;
Expand Down Expand Up @@ -64,10 +65,12 @@ public class AffectedVersionAttribution implements Serializable {

@Persistent
@Column(name = "FIRST_SEEN", allowsNull = "false")
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date firstSeen;

@Persistent
@Column(name = "LAST_SEEN", allowsNull = "false")
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date lastSeen;

@Persistent
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/dependencytrack/model/AnalysisComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
Expand Down Expand Up @@ -57,6 +58,7 @@ public class AnalysisComment implements Serializable {
@Persistent(defaultFetchGroup = "true")
@Column(name = "TIMESTAMP", allowsNull = "false")
@NotNull
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date timestamp;

@Persistent(defaultFetchGroup = "true")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/dependencytrack/model/Bom.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
Expand Down Expand Up @@ -73,6 +74,7 @@ public String getFormatLongName() {
@Persistent
@Column(name = "IMPORTED", allowsNull = "false")
@NotNull
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date imported;

@Persistent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
Expand Down Expand Up @@ -61,18 +62,22 @@ public class DependencyMetrics implements Serializable {

@Persistent
@Column(name = "CRITICAL")
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private int critical;

@Persistent
@Column(name = "HIGH")
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private int high;

@Persistent
@Column(name = "MEDIUM")
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private int medium;

@Persistent
@Column(name = "LOW")
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private int low;

@Persistent
Expand Down Expand Up @@ -167,12 +172,14 @@ public class DependencyMetrics implements Serializable {
@Column(name = "FIRST_OCCURRENCE", allowsNull = "false")
@NotNull
@Index(name = "DEPENDENCYMETRICS_FIRST_OCCURRENCE_IDX")
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date firstOccurrence;

@Persistent
@Column(name = "LAST_OCCURRENCE", allowsNull = "false")
@NotNull
@Index(name = "DEPENDENCYMETRICS_LAST_OCCURRENCE_IDX")
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date lastOccurrence;

public long getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import org.dependencytrack.tasks.scanners.AnalyzerIdentity;

import javax.jdo.annotations.Column;
Expand Down Expand Up @@ -55,6 +56,7 @@ public class FindingAttribution implements Serializable {
@Persistent
@Column(name = "ATTRIBUTED_ON", allowsNull = "false")
@NotNull
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date attributedOn;

@Persistent
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/dependencytrack/model/PolicyViolation.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
Expand Down Expand Up @@ -79,6 +80,7 @@ public enum Type {

@Persistent
@Column(name = "TIMESTAMP", allowsNull = "false")
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date timestamp;

@Persistent
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/dependencytrack/model/PortfolioMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@ public class PortfolioMetrics implements Serializable {

@Persistent
@Column(name = "CRITICAL")
@Schema(required = true)
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private int critical;

@Persistent
@Column(name = "HIGH")
@Schema(required = true)
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private int high;

@Persistent
@Column(name = "MEDIUM")
@Schema(required = true)
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private int medium;

@Persistent
@Column(name = "LOW")
@Schema(required = true)
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private int low;

@Persistent
Expand Down Expand Up @@ -178,14 +178,14 @@ public class PortfolioMetrics implements Serializable {
@Column(name = "FIRST_OCCURRENCE", allowsNull = "false")
@NotNull
@Index(name = "PORTFOLIOMETRICS_FIRST_OCCURRENCE_IDX")
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, type = "number")
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date firstOccurrence;

@Persistent
@Column(name = "LAST_OCCURRENCE", allowsNull = "false")
@NotNull
@Index(name = "PORTFOLIOMETRICS_LAST_OCCURRENCE_IDX")
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, type = "number")
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date lastOccurrence;

public long getId() {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/dependencytrack/model/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public enum FetchGroup {
@Persistent
@Index(name = "PROJECT_LASTBOMIMPORT_IDX")
@Column(name = "LAST_BOM_IMPORTED")
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date lastBomImport;

/**
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/org/dependencytrack/model/ProjectMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,28 @@ public class ProjectMetrics implements Serializable {

@Persistent
@Column(name = "PROJECT_ID", allowsNull = "false")
@Schema(required = true)
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private Project project;

@Persistent
@Column(name = "CRITICAL")
@Schema(required = true)
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private int critical;

@Persistent
@Column(name = "HIGH")
@Schema(required = true)
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private int high;

@Persistent
@Column(name = "MEDIUM")
@Schema(required = true)
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private int medium;

@Persistent
@Column(name = "LOW")
@NotNull
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private int low;

@Persistent
Expand Down Expand Up @@ -174,14 +175,14 @@ public class ProjectMetrics implements Serializable {
@Column(name = "FIRST_OCCURRENCE", allowsNull = "false")
@NotNull
@Index(name = "PROJECTMETRICS_FIRST_OCCURRENCE_IDX")
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, type = "number")
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date firstOccurrence;

@Persistent
@Column(name = "LAST_OCCURRENCE", allowsNull = "false")
@NotNull
@Index(name = "PROJECTMETRICS_LAST_OCCURRENCE_IDX")
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, type = "number")
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date lastOccurrence;

public long getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
Expand Down Expand Up @@ -85,6 +86,7 @@ public class RepositoryMetaComponent implements Serializable {
*/
@Persistent
@Column(name = "PUBLISHED")
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date published;

/**
Expand All @@ -94,6 +96,7 @@ public class RepositoryMetaComponent implements Serializable {
@Column(name = "LAST_CHECK", allowsNull = "false")
@Index(name = "REPOSITORY_META_COMPONENT_LASTCHECK_IDX")
@NotNull
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date lastCheck;


Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/dependencytrack/model/Vex.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
Expand Down Expand Up @@ -71,6 +73,7 @@ public String getFormatLongName() {
@Persistent
@Column(name = "IMPORTED", allowsNull = "false")
@NotNull
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date imported;

@Persistent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
Expand Down Expand Up @@ -57,6 +58,7 @@ public class ViolationAnalysisComment implements Serializable {
@Persistent(defaultFetchGroup = "true")
@Column(name = "TIMESTAMP", allowsNull = "false")
@NotNull
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date timestamp;

@Persistent(defaultFetchGroup = "true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
Expand Down Expand Up @@ -62,6 +63,7 @@ public class VulnerabilityMetrics implements Serializable {
@Persistent
@Column(name = "MEASURED_AT", allowsNull = "false")
@NotNull
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date measuredAt;

public long getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ public class ProblemDetails {
@Schema(
description = "HTTP status code generated by the origin server for this occurrence of the problem",
example = "400",
required = true
requiredMode = Schema.RequiredMode.REQUIRED
)
private Integer status;

@Schema(
description = "Short, human-readable summary of the problem type",
example = "Example title",
required = true
requiredMode = Schema.RequiredMode.REQUIRED
)
private String title;

@Schema(
description = "Human-readable explanation specific to this occurrence of the problem",
example = "Example detail",
required = true
requiredMode = Schema.RequiredMode.REQUIRED
)
private String detail;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class IsTokenBeingProcessedResponse implements Serializable {

private static final long serialVersionUID = -7592468766586686855L;

@Schema(required = true)
@Schema(requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean processing;

public void setProcessing(Boolean processing) {
Expand Down

0 comments on commit 2980188

Please sign in to comment.