Skip to content

Commit

Permalink
Fix OpenAPI types of UNIX timestamp fields (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
nscuro authored Aug 8, 2024
1 parent 1419fe7 commit ad44944
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 23 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
4 changes: 3 additions & 1 deletion src/main/java/org/dependencytrack/model/AnalysisComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
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 jakarta.validation.constraints.NotNull;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

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
5 changes: 4 additions & 1 deletion src/main/java/org/dependencytrack/model/Bom.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

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

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Unique;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
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 Expand Up @@ -104,6 +106,7 @@ public String getFormatLongName() {

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

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

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

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.Index;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

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 @@ -179,12 +184,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,8 @@

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

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
Expand All @@ -28,7 +30,6 @@
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Unique;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
Expand All @@ -54,6 +55,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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
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 jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.Extension;
Expand All @@ -31,9 +35,6 @@
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Unique;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;

Expand Down Expand Up @@ -89,11 +90,13 @@ public void setSha512(String sha512) {
*/
@Persistent
@Column(name = "PUBLISHED_AT")
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date publishedAt;

@Persistent
@Column(name = "LAST_FETCH")
@Index(name = "LAST_FETCH_IDX")
@Schema(type = "integer", format = "int64", requiredMode = Schema.RequiredMode.REQUIRED, description = "UNIX epoch timestamp in milliseconds")
private Date lastFetch;

@Persistent
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/dependencytrack/model/PolicyViolation.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
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 jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
Expand All @@ -30,9 +34,6 @@
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Unique;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
Expand Down Expand Up @@ -82,6 +83,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
4 changes: 2 additions & 2 deletions src/main/java/org/dependencytrack/model/PortfolioMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,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
9 changes: 5 additions & 4 deletions src/main/java/org/dependencytrack/model/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
import com.github.packageurl.MalformedPackageURLException;
import com.github.packageurl.PackageURL;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import org.dependencytrack.persistence.converter.OrganizationalEntityJsonConverter;
import org.dependencytrack.resources.v1.serializers.CustomPackageURLSerializer;

Expand All @@ -50,10 +54,6 @@
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Serialized;
import javax.jdo.annotations.Unique;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
Expand Down Expand Up @@ -262,6 +262,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
4 changes: 2 additions & 2 deletions src/main/java/org/dependencytrack/model/ProjectMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,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,14 +20,15 @@

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

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.Index;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

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
5 changes: 4 additions & 1 deletion src/main/java/org/dependencytrack/model/Vex.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@

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

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Unique;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
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,13 +22,14 @@
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 jakarta.validation.constraints.NotNull;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

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,13 +20,14 @@

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

import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

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
Loading

0 comments on commit ad44944

Please sign in to comment.