forked from Hyperfoil/Horreum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strongly typed Datastore configuration - Fixes Hyperfoil#2088
- Loading branch information
1 parent
9038d5c
commit e12720c
Showing
19 changed files
with
810 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 36 additions & 4 deletions
40
...-api/src/main/java/io/hyperfoil/tools/horreum/api/data/datastore/BaseDatastoreConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,51 @@ | ||
package io.hyperfoil.tools.horreum.api.data.datastore; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; | ||
import org.eclipse.microprofile.openapi.annotations.media.DiscriminatorMapping; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
|
||
import io.hyperfoil.tools.horreum.api.data.datastore.auth.APIKeyAuth; | ||
import io.hyperfoil.tools.horreum.api.data.datastore.auth.NoAuth; | ||
import io.hyperfoil.tools.horreum.api.data.datastore.auth.UsernamePassAuth; | ||
|
||
public abstract class BaseDatastoreConfig { | ||
|
||
@Schema(type = SchemaType.BOOLEAN, required = true, description = "Built In") | ||
public Boolean builtIn = true; | ||
@NotNull | ||
@JsonProperty(required = true) | ||
@Schema(type = SchemaType.OBJECT, discriminatorProperty = "type", discriminatorMapping = { | ||
@DiscriminatorMapping(schema = NoAuth.class, value = NoAuth._TYPE), | ||
@DiscriminatorMapping(schema = APIKeyAuth.class, value = APIKeyAuth._TYPE), | ||
@DiscriminatorMapping(schema = UsernamePassAuth.class, value = UsernamePassAuth._TYPE) | ||
}, oneOf = { //subtype mapping for openapi | ||
NoAuth.class, | ||
APIKeyAuth.class, | ||
UsernamePassAuth.class | ||
}) | ||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") | ||
@JsonSubTypes({ //subtype mapping for jackson | ||
@JsonSubTypes.Type(value = NoAuth.class, name = NoAuth._TYPE), | ||
@JsonSubTypes.Type(value = APIKeyAuth.class, name = APIKeyAuth._TYPE), | ||
@JsonSubTypes.Type(value = UsernamePassAuth.class, name = UsernamePassAuth._TYPE) | ||
}) | ||
public Object authentication; //the python generator is failing if this is a concrete type | ||
|
||
public BaseDatastoreConfig() { | ||
} | ||
@Schema(type = SchemaType.BOOLEAN, required = true, description = "Built In") | ||
public Boolean builtIn; | ||
|
||
public BaseDatastoreConfig(Boolean builtIn) { | ||
this.builtIn = builtIn; | ||
} | ||
|
||
public BaseDatastoreConfig() { | ||
this.builtIn = false; | ||
} | ||
|
||
public abstract String validateConfig(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.