🏴‍☠️ Add OAS and SwaggerUI config

pull/4/head
Alexis Drai 2 years ago
parent bfa27e38ea
commit 220b2e39a9

@ -83,10 +83,15 @@ You can run the application in dev mode using:
## API testing ## API testing
### 🏴‍☠️ SwaggerUI
Thanks to this project's OpenAPI specs, you can explore the API in a lot of ways.
A popular choice is SwaggerUI -- after you run the app, just go to http://localhost:8080/q/swagger-ui and have fun.
### 🩺 API testing tools ### 🩺 API testing tools
It is recommended to use an API testing tool such as [Postman](https://www.postman.com/) You can use an API testing tool such as [Postman](https://www.postman.com/)
or [Insomnia](https://insomnia.rest/), while playing around with this app. or [Insomnia](https://insomnia.rest/) to test this app.
### 📱 Front end (later) ### 📱 Front end (later)

@ -16,6 +16,8 @@ dependencies {
implementation 'io.quarkus:quarkus-mongodb-client:3.0.0.Alpha6' implementation 'io.quarkus:quarkus-mongodb-client:3.0.0.Alpha6'
implementation 'org.mongodb:mongodb-driver-sync:4.9.1' implementation 'org.mongodb:mongodb-driver-sync:4.9.1'
implementation 'org.jetbrains:annotations:24.0.1' implementation 'org.jetbrains:annotations:24.0.1'
implementation 'io.quarkus:quarkus-smallrye-openapi:2.16.4.Final'
implementation 'io.quarkus:quarkus-swagger-ui:2.16.4.Final'
testImplementation 'io.quarkus:quarkus-junit5:3.0.0.Alpha6' testImplementation 'io.quarkus:quarkus-junit5:3.0.0.Alpha6'
testImplementation 'io.rest-assured:rest-assured:5.3.0' testImplementation 'io.rest-assured:rest-assured:5.3.0'
} }

@ -23,9 +23,9 @@
* level: int * level: int
* pokedexId: int * pokedexId: int
* evoStage: int * evoStage: int
* (_indexed_: "species" is calculated as evo_track[evo_stage], and would often be queried) * (_indexed_: "species" is calculated as evoTrack[evoStage], and would often be queried)
* evoTrack: array of strings (therefore "species" is evo_track[evo_stage], and "evo_base" is evo_track[0]) * evoTrack: array of strings (therefore "species" is evoTrack[evoStage], and "evoBase" is evoTrack[0])
* (_indexed_: "species" is calculated as evo_track[evo_stage], and would be queried often) * (_indexed_: "species" is calculated as evoTrack[evoStage], and would be queried often)
* trainer: ObjectId? (reference to a trainer) (but can be "wild" instead, if ref is null) * trainer: ObjectId? (reference to a trainer) (but can be "wild" instead, if ref is null)
* (_indexed_: could be queried often in a dashboard situation) * (_indexed_: could be queried often in a dashboard situation)
* types: embedded type, or array of embedded types * types: embedded type, or array of embedded types
@ -38,7 +38,6 @@
* name: string * name: string
* (_indexed_: would often be queried in a dashboard situation) * (_indexed_: would often be queried in a dashboard situation)
* category: string (can be "physical", "special", or "status") * category: string (can be "physical", "special", or "status")
* pp: int
* power: int * power: int
* (_indexed_: would often be used in sorts, in a dashboard situation) * (_indexed_: would often be used in sorts, in a dashboard situation)
* accuracy: int * accuracy: int
@ -56,18 +55,18 @@
## Relationships ## Relationships
* trainers.pastOpponents: one-to-many and reflexive - [ ] trainers.pastOpponents: one-to-many and reflexive
* => referencing * => referencing
* trainers.pokemongs: one-to-many - [ ] trainers.pokemongs: one-to-many
* => referencing + denormalizing on "nickname" and "species" * => referencing + denormalizing on "nickname" and "species"
* pokemongs.trainer: many-to-one - [ ] pokemongs.trainer: many-to-one
* => referencing * => referencing
* pokemongs.types: one-to-few [1;2] - [x] pokemongs.types: one-to-few [1;2]
* => embedding * => embedding
* pokemongs.moveSet: one-to-few [1;4] but will also need to be queried independently - [x] pokemongs.moveSet: one-to-few [1;4] but will also need to be queried independently
* => referencing + denormalizing on "name" * => referencing + denormalizing on "name"
* moves.type: one-to-one [1;1] - [x] moves.type: one-to-one [1;1]
* => embedding * => embedding
* types.weakAgainst & types.effectiveAgainst: one-to-few, but reflexive - [x] types.weakAgainst & types.effectiveAgainst: one-to-few, but reflexive
* => denormalizing on "name" * => denormalizing on "name"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 34 KiB

@ -54,7 +54,9 @@ public class PokemongCodec extends GenericCodec<Pokemong> {
.collect(Collectors.toList()); .collect(Collectors.toList());
doc.put("evoTrack", evoTrack); doc.put("evoTrack", evoTrack);
doc.put("trainer", pokemong.getTrainer()); if(pokemong.getTrainer() != null) {
doc.put("trainer", new ObjectId(pokemong.getTrainer()));
}
List<Document> types = pokemong.getTypes() List<Document> types = pokemong.getTypes()
.stream() .stream()
@ -126,7 +128,7 @@ public class PokemongCodec extends GenericCodec<Pokemong> {
.collect(Collectors.toList()); .collect(Collectors.toList());
pokemong.setEvoTrack(evoTrack); pokemong.setEvoTrack(evoTrack);
pokemong.setTrainer(document.getObjectId("trainer")); pokemong.setTrainer(document.getString("trainer"));
List<Type> types = document.getList("types", Document.class) List<Type> types = document.getList("types", Document.class)
.stream() .stream()

@ -2,7 +2,6 @@ package fr.uca.iut.entities;
import com.mongodb.lang.Nullable; import com.mongodb.lang.Nullable;
import fr.uca.iut.utils.enums.PokemongName; import fr.uca.iut.utils.enums.PokemongName;
import org.bson.types.ObjectId;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Collections; import java.util.Collections;
@ -20,7 +19,7 @@ public class Pokemong extends GenericEntity {
private Integer evoStage; private Integer evoStage;
private List<PokemongName> evoTrack; private List<PokemongName> evoTrack;
@Nullable @Nullable
private ObjectId trainer; private String trainer;
private List<Type> types; private List<Type> types;
/** /**
@ -80,11 +79,11 @@ public class Pokemong extends GenericEntity {
} }
@Nullable @Nullable
public ObjectId getTrainer() { public String getTrainer() {
return trainer; return trainer;
} }
public void setTrainer(@Nullable ObjectId trainer) { public void setTrainer(@Nullable String trainer) {
this.trainer = trainer; this.trainer = trainer;
} }

@ -11,7 +11,7 @@ import jakarta.inject.Inject;
@ApplicationScoped @ApplicationScoped
public class MoveRepository extends GenericRepository<Move> { public class MoveRepository extends GenericRepository<Move> {
// FIXME? // FIX?ME
/** /**
* Warns that "Unsatisfied dependency: no bean matches the injection point" * Warns that "Unsatisfied dependency: no bean matches the injection point"
* but the app works * but the app works

@ -17,7 +17,7 @@ import java.util.List;
@ApplicationScoped @ApplicationScoped
public class PokemongRepository extends GenericRepository<Pokemong> { public class PokemongRepository extends GenericRepository<Pokemong> {
// FIXME? // FIX?ME
/** /**
* Warns that "Unsatisfied dependency: no bean matches the injection point" * Warns that "Unsatisfied dependency: no bean matches the injection point"
* but the app works * but the app works

File diff suppressed because it is too large Load Diff

@ -1,2 +1,3 @@
quarkus.mongodb.connection-string=mongodb+srv://<username>:<password>@<cluster>.<node>.mongodb.net quarkus.mongodb.connection-string=mongodb+srv://<username>:<password>@<cluster>.<node>.mongodb.net
quarkus.mongodb.database=<database> quarkus.mongodb.database=<database>
quarkus.smallrye-openapi.path=META-INF/openapi.yaml

Loading…
Cancel
Save