Merge pull request #7847 from deathbeam/swagger-static

Add Swagger static document generation
This commit is contained in:
Adam
2019-03-14 16:07:17 -04:00
committed by GitHub
18 changed files with 408 additions and 35 deletions

View File

@@ -180,6 +180,48 @@
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version> <version>${spring.boot.version}</version>
</plugin> </plugin>
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.1.8</version>
<configuration>
<apiSources>
<apiSource>
<springmvc>true</springmvc>
<locations>
<location>net.runelite</location>
</locations>
<schemes>
<scheme>https</scheme>
</schemes>
<host>api.runelite.net</host>
<basePath>/runelite-${project.version}</basePath>
<info>
<title>${project.parent.name} HTTP API</title>
<version>${project.version}</version>
<description>${project.description}</description>
<license>
<url>https://tldrlegal.com/license/bsd-2-clause-license-(freebsd)</url>
<name>BSD 2-Clause "Simplified"</name>
</license>
</info>
<templatePath>${basedir}/src/main/templates/template.html.hbs</templatePath>
<swaggerDirectory>${project.build.directory}/swagger-ui</swaggerDirectory>
<outputPath>${project.build.directory}/site/api.html</outputPath>
<attachSwaggerArtifact>true</attachSwaggerArtifact>
<outputFormats>json</outputFormats>
</apiSource>
</apiSources>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@@ -52,6 +52,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@@ -135,7 +136,7 @@ public class AccountService
} }
} }
@RequestMapping("/login") @GetMapping("/login")
public OAuthResponse login(@RequestParam UUID uuid) public OAuthResponse login(@RequestParam UUID uuid)
{ {
State state = new State(); State state = new State();
@@ -162,7 +163,7 @@ public class AccountService
return lr; return lr;
} }
@RequestMapping("/callback") @GetMapping("/callback")
public Object callback( public Object callback(
HttpServletRequest request, HttpServletRequest request,
HttpServletResponse response, HttpServletResponse response,
@@ -250,7 +251,7 @@ public class AccountService
} }
} }
@RequestMapping("/logout") @GetMapping("/logout")
public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException
{ {
SessionEntry session = auth.handle(request, response); SessionEntry session = auth.handle(request, response);
@@ -268,7 +269,7 @@ public class AccountService
} }
} }
@RequestMapping("/session-check") @GetMapping("/session-check")
public void sessionCheck(HttpServletRequest request, HttpServletResponse response) throws IOException public void sessionCheck(HttpServletRequest request, HttpServletResponse response) throws IOException
{ {
auth.handle(request, response); auth.handle(request, response);

View File

@@ -62,6 +62,7 @@ import net.runelite.http.service.cache.beans.IndexEntry;
import net.runelite.http.service.util.exception.NotFoundException; import net.runelite.http.service.util.exception.NotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -75,7 +76,7 @@ public class CacheController
@Autowired @Autowired
private CacheService cacheService; private CacheService cacheService;
@RequestMapping("/") @GetMapping("/")
public List<Cache> listCaches() public List<Cache> listCaches()
{ {
return cacheService.listCaches().stream() return cacheService.listCaches().stream()
@@ -83,7 +84,7 @@ public class CacheController
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@RequestMapping("{cacheId}") @GetMapping("{cacheId}")
public List<CacheIndex> listIndexes(@PathVariable int cacheId) public List<CacheIndex> listIndexes(@PathVariable int cacheId)
{ {
CacheEntry cache = cacheService.findCache(cacheId); CacheEntry cache = cacheService.findCache(cacheId);
@@ -99,7 +100,7 @@ public class CacheController
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@RequestMapping("{cacheId}/{indexId}") @GetMapping("{cacheId}/{indexId}")
public List<CacheArchive> listArchives(@PathVariable int cacheId, public List<CacheArchive> listArchives(@PathVariable int cacheId,
@PathVariable int indexId) @PathVariable int indexId)
{ {
@@ -122,7 +123,7 @@ public class CacheController
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@RequestMapping("{cacheId}/{indexId}/{archiveId}") @GetMapping("{cacheId}/{indexId}/{archiveId}")
public CacheArchive getCacheArchive(@PathVariable int cacheId, public CacheArchive getCacheArchive(@PathVariable int cacheId,
@PathVariable int indexId, @PathVariable int indexId,
@PathVariable int archiveId) @PathVariable int archiveId)
@@ -149,7 +150,7 @@ public class CacheController
archiveEntry.getNameHash(), archiveEntry.getRevision()); archiveEntry.getNameHash(), archiveEntry.getRevision());
} }
@RequestMapping("{cacheId}/{indexId}/{archiveId}/data") @GetMapping("{cacheId}/{indexId}/{archiveId}/data")
public byte[] getArchiveData( public byte[] getArchiveData(
@PathVariable int cacheId, @PathVariable int cacheId,
@PathVariable int indexId, @PathVariable int indexId,
@@ -200,7 +201,7 @@ public class CacheController
return archiveEntry; return archiveEntry;
} }
@RequestMapping("item/{itemId}") @GetMapping("item/{itemId}")
public ItemDefinition getItem(@PathVariable int itemId) throws IOException public ItemDefinition getItem(@PathVariable int itemId) throws IOException
{ {
ArchiveEntry archiveEntry = findConfig(ConfigType.ITEM); ArchiveEntry archiveEntry = findConfig(ConfigType.ITEM);
@@ -221,7 +222,7 @@ public class CacheController
return itemdef; return itemdef;
} }
@RequestMapping(path = "item/{itemId}/image", produces = "image/png") @GetMapping(path = "item/{itemId}/image", produces = "image/png")
public ResponseEntity<byte[]> getItemImage( public ResponseEntity<byte[]> getItemImage(
@PathVariable int itemId, @PathVariable int itemId,
@RequestParam(defaultValue = "1") int quantity, @RequestParam(defaultValue = "1") int quantity,
@@ -313,7 +314,7 @@ public class CacheController
return ResponseEntity.ok(bao.toByteArray()); return ResponseEntity.ok(bao.toByteArray());
} }
@RequestMapping("object/{objectId}") @GetMapping("object/{objectId}")
public ObjectDefinition getObject( public ObjectDefinition getObject(
@PathVariable int objectId @PathVariable int objectId
) throws IOException ) throws IOException
@@ -336,7 +337,7 @@ public class CacheController
return objectdef; return objectdef;
} }
@RequestMapping("npc/{npcId}") @GetMapping("npc/{npcId}")
public NpcDefinition getNpc( public NpcDefinition getNpc(
@PathVariable int npcId @PathVariable int npcId
) throws IOException ) throws IOException

View File

@@ -31,6 +31,7 @@ import net.runelite.http.api.config.Configuration;
import net.runelite.http.service.account.AuthFilter; import net.runelite.http.service.account.AuthFilter;
import net.runelite.http.service.account.beans.SessionEntry; import net.runelite.http.service.account.beans.SessionEntry;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@@ -52,7 +53,7 @@ public class ConfigController
this.authFilter = authFilter; this.authFilter = authFilter;
} }
@RequestMapping @GetMapping
public Configuration get(HttpServletRequest request, HttpServletResponse response) throws IOException public Configuration get(HttpServletRequest request, HttpServletResponse response) throws IOException
{ {
SessionEntry session = authFilter.handle(request, response); SessionEntry session = authFilter.handle(request, response);

View File

@@ -30,6 +30,7 @@ import static net.runelite.http.service.examine.ExamineType.OBJECT;
import net.runelite.http.service.item.ItemEntry; import net.runelite.http.service.item.ItemEntry;
import net.runelite.http.service.item.ItemService; import net.runelite.http.service.item.ItemService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@@ -50,19 +51,19 @@ public class ExamineController
this.itemService = itemService; this.itemService = itemService;
} }
@RequestMapping("/npc/{id}") @GetMapping("/npc/{id}")
public String getNpc(@PathVariable int id) public String getNpc(@PathVariable int id)
{ {
return examineService.get(NPC, id); return examineService.get(NPC, id);
} }
@RequestMapping("/object/{id}") @GetMapping("/object/{id}")
public String getObject(@PathVariable int id) public String getObject(@PathVariable int id)
{ {
return examineService.get(OBJECT, id); return examineService.get(OBJECT, id);
} }
@RequestMapping("/item/{id}") @GetMapping("/item/{id}")
public String getItem(@PathVariable int id) public String getItem(@PathVariable int id)
{ {
// Tradeable item examine info is available from the Jagex item API // Tradeable item examine info is available from the Jagex item API

View File

@@ -38,6 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.CacheControl; import org.springframework.http.CacheControl;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@@ -95,7 +96,7 @@ public class FeedController
feedResult = new FeedResult(items); feedResult = new FeedResult(items);
} }
@RequestMapping @GetMapping
public ResponseEntity<FeedResult> getFeed() public ResponseEntity<FeedResult> getFeed()
{ {
if (feedResult == null) if (feedResult == null)

View File

@@ -34,6 +34,7 @@ import net.runelite.http.service.util.HiscoreEndpointEditor;
import net.runelite.http.service.xp.XpTrackerService; import net.runelite.http.service.xp.XpTrackerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@@ -50,7 +51,7 @@ public class HiscoreController
@Autowired @Autowired
private XpTrackerService xpTrackerService; private XpTrackerService xpTrackerService;
@RequestMapping("/{endpoint}") @GetMapping("/{endpoint}")
public HiscoreResult lookup(@PathVariable HiscoreEndpoint endpoint, @RequestParam String username) throws ExecutionException public HiscoreResult lookup(@PathVariable HiscoreEndpoint endpoint, @RequestParam String username) throws ExecutionException
{ {
HiscoreResult result = hiscoreService.lookupUsername(username, endpoint); HiscoreResult result = hiscoreService.lookupUsername(username, endpoint);
@@ -68,7 +69,7 @@ public class HiscoreController
return result; return result;
} }
@RequestMapping("/{endpoint}/{skillName}") @GetMapping("/{endpoint}/{skillName}")
public SingleHiscoreSkillResult singleSkillLookup(@PathVariable HiscoreEndpoint endpoint, @PathVariable String skillName, @RequestParam String username) throws ExecutionException public SingleHiscoreSkillResult singleSkillLookup(@PathVariable HiscoreEndpoint endpoint, @PathVariable String skillName, @RequestParam String username) throws ExecutionException
{ {
HiscoreSkill skill = HiscoreSkill.valueOf(skillName.toUpperCase()); HiscoreSkill skill = HiscoreSkill.valueOf(skillName.toUpperCase());

View File

@@ -40,6 +40,7 @@ import net.runelite.http.api.item.SearchResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.CacheControl; import org.springframework.http.CacheControl;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -78,7 +79,7 @@ public class ItemController
.toArray(ItemPrice[]::new), 30, TimeUnit.MINUTES); .toArray(ItemPrice[]::new), 30, TimeUnit.MINUTES);
} }
@RequestMapping("/{itemId}") @GetMapping("/{itemId}")
public Item getItem(HttpServletResponse response, @PathVariable int itemId) public Item getItem(HttpServletResponse response, @PathVariable int itemId)
{ {
ItemEntry item = itemService.getItem(itemId); ItemEntry item = itemService.getItem(itemId);
@@ -91,7 +92,7 @@ public class ItemController
return null; return null;
} }
@RequestMapping(path = "/{itemId}/icon", produces = "image/gif") @GetMapping(path = "/{itemId}/icon", produces = "image/gif")
public ResponseEntity<byte[]> getIcon(@PathVariable int itemId) public ResponseEntity<byte[]> getIcon(@PathVariable int itemId)
{ {
ItemEntry item = itemService.getItem(itemId); ItemEntry item = itemService.getItem(itemId);
@@ -104,7 +105,7 @@ public class ItemController
return ResponseEntity.notFound().build(); return ResponseEntity.notFound().build();
} }
@RequestMapping(path = "/{itemId}/icon/large", produces = "image/gif") @GetMapping(path = "/{itemId}/icon/large", produces = "image/gif")
public ResponseEntity<byte[]> getIconLarge(HttpServletResponse response, @PathVariable int itemId) public ResponseEntity<byte[]> getIconLarge(HttpServletResponse response, @PathVariable int itemId)
{ {
ItemEntry item = itemService.getItem(itemId); ItemEntry item = itemService.getItem(itemId);
@@ -117,7 +118,7 @@ public class ItemController
return ResponseEntity.notFound().build(); return ResponseEntity.notFound().build();
} }
@RequestMapping("/{itemId}/price") @GetMapping("/{itemId}/price")
public ResponseEntity<ItemPrice> itemPrice( public ResponseEntity<ItemPrice> itemPrice(
@PathVariable int itemId, @PathVariable int itemId,
@RequestParam(required = false) Instant time @RequestParam(required = false) Instant time
@@ -179,7 +180,7 @@ public class ItemController
.body(itemPrice); .body(itemPrice);
} }
@RequestMapping("/search") @GetMapping("/search")
public SearchResult search(@RequestParam String query) public SearchResult search(@RequestParam String query)
{ {
List<ItemEntry> result = itemService.search(query); List<ItemEntry> result = itemService.search(query);
@@ -193,7 +194,7 @@ public class ItemController
return searchResult; return searchResult;
} }
@RequestMapping("/price") @GetMapping("/price")
public ItemPrice[] prices(@RequestParam("id") int[] itemIds) public ItemPrice[] prices(@RequestParam("id") int[] itemIds)
{ {
if (itemIds.length > MAX_BATCH_LOOKUP) if (itemIds.length > MAX_BATCH_LOOKUP)
@@ -216,7 +217,7 @@ public class ItemController
.toArray(ItemPrice[]::new); .toArray(ItemPrice[]::new);
} }
@RequestMapping("/prices") @GetMapping("/prices")
public ResponseEntity<ItemPrice[]> prices() public ResponseEntity<ItemPrice[]> prices()
{ {
return ResponseEntity.ok() return ResponseEntity.ok()

View File

@@ -35,6 +35,7 @@ import net.runelite.http.service.account.AuthFilter;
import net.runelite.http.service.account.beans.SessionEntry; import net.runelite.http.service.account.beans.SessionEntry;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
@@ -65,7 +66,7 @@ public class LootTrackerController
response.setStatus(HttpStatusCodes.STATUS_CODE_OK); response.setStatus(HttpStatusCodes.STATUS_CODE_OK);
} }
@RequestMapping @GetMapping
public Collection<LootRecord> getLootRecords(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "count", defaultValue = "1024") int count, @RequestParam(value = "start", defaultValue = "0") int start) throws IOException public Collection<LootRecord> getLootRecords(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "count", defaultValue = "1024") int count, @RequestParam(value = "start", defaultValue = "0") int start) throws IOException
{ {
SessionEntry e = auth.handle(request, response); SessionEntry e = auth.handle(request, response);

View File

@@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.CacheControl; import org.springframework.http.CacheControl;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@@ -45,7 +46,7 @@ public class OSBGrandExchangeController
this.grandExchangeService = grandExchangeService; this.grandExchangeService = grandExchangeService;
} }
@RequestMapping @GetMapping
public ResponseEntity<GrandExchangeEntry> get(@RequestParam("itemId") int itemId) throws ExecutionException public ResponseEntity<GrandExchangeEntry> get(@RequestParam("itemId") int itemId) throws ExecutionException
{ {
GrandExchangeEntry grandExchangeEntry = grandExchangeService.get(itemId); GrandExchangeEntry grandExchangeEntry = grandExchangeService.get(itemId);

View File

@@ -31,6 +31,7 @@ import java.io.IOException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@@ -55,7 +56,7 @@ public class SpriteController
} }
}); });
@RequestMapping(produces = "image/png") @GetMapping(produces = "image/png")
public ResponseEntity<byte[]> getSprite( public ResponseEntity<byte[]> getSprite(
@RequestParam int spriteId, @RequestParam int spriteId,
@RequestParam(defaultValue = "0") int frameId @RequestParam(defaultValue = "0") int frameId

View File

@@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.CacheControl; import org.springframework.http.CacheControl;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@@ -45,7 +46,7 @@ public class WorldController
private WorldResult worldResult; private WorldResult worldResult;
@RequestMapping @GetMapping
public ResponseEntity<WorldResult> listWorlds() throws IOException public ResponseEntity<WorldResult> listWorlds() throws IOException
{ {
return ResponseEntity.ok() return ResponseEntity.ok()

View File

@@ -28,6 +28,7 @@ import java.time.Instant;
import net.runelite.http.api.xp.XpData; import net.runelite.http.api.xp.XpData;
import net.runelite.http.service.xp.beans.XpEntity; import net.runelite.http.service.xp.beans.XpEntity;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@@ -39,13 +40,13 @@ public class XpTrackerController
@Autowired @Autowired
private XpTrackerService xpTrackerService; private XpTrackerService xpTrackerService;
@RequestMapping("/update") @GetMapping("/update")
public void update(@RequestParam String username) public void update(@RequestParam String username)
{ {
xpTrackerService.tryUpdate(username); xpTrackerService.tryUpdate(username);
} }
@RequestMapping("/get") @GetMapping("/get")
public XpData get(@RequestParam String username, @RequestParam(required = false) Instant time) public XpData get(@RequestParam String username, @RequestParam(required = false) Instant time)
{ {
if (time == null) if (time == null)

View File

@@ -30,6 +30,7 @@ import net.runelite.http.api.xtea.XteaKey;
import net.runelite.http.api.xtea.XteaRequest; import net.runelite.http.api.xtea.XteaRequest;
import net.runelite.http.service.util.exception.NotFoundException; import net.runelite.http.service.util.exception.NotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@@ -49,7 +50,7 @@ public class XteaController
xteaService.submit(xteaRequest); xteaService.submit(xteaRequest);
} }
@RequestMapping @GetMapping
public List<XteaKey> get() public List<XteaKey> get()
{ {
return xteaService.get().stream() return xteaService.get().stream()
@@ -57,7 +58,7 @@ public class XteaController
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@RequestMapping("/{region}") @GetMapping("/{region}")
public XteaKey getRegion(@PathVariable int region) public XteaKey getRegion(@PathVariable int region)
{ {
XteaEntry xteaRegion = xteaService.getRegion(region); XteaEntry xteaRegion = xteaService.getRegion(region);

View File

@@ -0,0 +1,110 @@
{{#info}}
# {{title}}
{{join schemes " | "}}://{{host}}{{basePath}}
{{description}}
{{#contact}}
[**Contact the developer**](mailto:{{email}})
{{/contact}}
**Version** {{version}}
{{#if termsOfService}}
[**Terms of Service**]({{termsOfService}})
{{/if}}
{{/info}}
{{#if consumes}}__Consumes:__ {{join consumes ", "}}{{/if}}
{{#if produces}}__Produces:__ {{join produces ", "}}{{/if}}
{{#if securityDefinitions}}
# Security Definitions
{{> security}}
{{/if}}
<details>
<summary><b>Table Of Contents</b></summary>
[toc]
</details>
# APIs
{{#each paths}}
## {{@key}}
{{#this}}
{{#get}}
### GET
{{> operation}}
{{/get}}
{{#put}}
### PUT
{{> operation}}
{{/put}}
{{#post}}
### POST
{{> operation}}
{{/post}}
{{#delete}}
### DELETE
{{> operation}}
{{/delete}}
{{#option}}
### OPTION
{{> operation}}
{{/option}}
{{#patch}}
### PATCH
{{> operation}}
{{/patch}}
{{#head}}
### HEAD
{{> operation}}
{{/head}}
{{/this}}
{{/each}}
# Definitions
{{#each definitions}}
## <a name="/definitions/{{key}}">{{@key}}</a>
<table>
<tr>
<th>name</th>
<th>type</th>
<th>required</th>
<th>description</th>
<th>example</th>
</tr>
{{#each this.properties}}
<tr>
<td>{{@key}}</td>
<td>
{{#ifeq type "array"}}
{{#items.$ref}}
{{type}}[<a href="{{items.$ref}}">{{basename items.$ref}}</a>]
{{/items.$ref}}
{{^items.$ref}}{{type}}[{{items.type}}]{{/items.$ref}}
{{else}}
{{#$ref}}<a href="{{$ref}}">{{basename $ref}}</a>{{/$ref}}
{{^$ref}}{{type}}{{#format}} ({{format}}){{/format}}{{/$ref}}
{{/ifeq}}
</td>
<td>{{#required}}required{{/required}}{{^required}}optional{{/required}}</td>
<td>{{#description}}{{{description}}}{{/description}}{{^description}}-{{/description}}</td>
<td>{{example}}</td>
</tr>
{{/each}}
</table>
{{/each}}

View File

@@ -0,0 +1,71 @@
{{#deprecated}}-deprecated-{{/deprecated}}
<a id="{{operationId}}">{{summary}}</a>
{{description}}
{{#if externalDocs.url}}{{externalDocs.description}}. [See external documents for more details]({{externalDocs.url}})
{{/if}}
{{#if security}}
#### Security
{{/if}}
{{#security}}
{{#each this}}
* {{@key}}
{{#this}} * {{this}}
{{/this}}
{{/each}}
{{/security}}
#### Request
{{#if consumes}}__Content-Type:__ {{join consumes ", "}}{{/if}}
##### Parameters
{{#if parameters}}
<table>
<tr>
<th>Name</th>
<th>Located in</th>
<th>Required</th>
<th>Description</th>
<th>Default</th>
<th>Schema</th>
</tr>
{{/if}}
{{#parameters}}
<tr>
<th>{{name}}</th>
<td>{{in}}</td>
<td>{{#if required}}yes{{else}}no{{/if}}</td>
<td>{{description}}{{#if pattern}} (**Pattern**: `{{pattern}}`){{/if}}</td>
<td> - </td>
{{#ifeq in "body"}}
<td>
{{#ifeq schema.type "array"}}Array[<a href="{{schema.items.$ref}}">{{basename schema.items.$ref}}</a>]{{/ifeq}}
{{#schema.$ref}}<a href="{{schema.$ref}}">{{basename schema.$ref}}</a> {{/schema.$ref}}
</td>
{{else}}
{{#ifeq type "array"}}
<td>Array[{{items.type}}] ({{collectionFormat}})</td>
{{else}}
<td>{{type}} {{#format}}({{format}}){{/format}}</td>
{{/ifeq}}
{{/ifeq}}
</tr>
{{/parameters}}
{{#if parameters}}
</table>
{{/if}}
#### Response
{{#if produces}}__Content-Type:__ {{join produces ", "}}{{/if}}
| Status Code | Reason | Response Model |
|-------------|-------------|----------------|
{{#each responses}}| {{@key}} | {{description}} | {{#schema.$ref}}<a href="{{schema.$ref}}">{{basename schema.$ref}}</a>{{/schema.$ref}}{{#ifeq schema.type "array"}}Array[<a href="{{schema.items.$ref}}">{{basename schema.items.$ref}}</a>]{{/ifeq}}{{^schema}} - {{/schema}}|
{{/each}}

View File

@@ -0,0 +1,88 @@
{{#each securityDefinitions}}
### {{@key}}
{{#this}}
{{#ifeq type "oauth2"}}
<table>
<tr>
<th>type</th>
<th colspan="2">{{type}}</th>
</tr>
{{#if description}}
<tr>
<th>description</th>
<th colspan="2">{{description}}</th>
</tr>
{{/if}}
{{#if authorizationUrl}}
<tr>
<th>authorizationUrl</th>
<th colspan="2">{{authorizationUrl}}</th>
</tr>
{{/if}}
{{#if flow}}
<tr>
<th>flow</th>
<th colspan="2">{{flow}}</th>
</tr>
{{/if}}
{{#if tokenUrl}}
<tr>
<th>tokenUrl</th>
<th colspan="2">{{tokenUrl}}</th>
</tr>
{{/if}}
{{#if scopes}}
<tr>
<td rowspan="3">scopes</td>
{{#each scopes}}
<td>{{@key}}</td>
<td>{{this}}</td>
</tr>
<tr>
{{/each}}
</tr>
{{/if}}
</table>
{{/ifeq}}
{{#ifeq type "apiKey"}}
<table>
<tr>
<th>type</th>
<th colspan="2">{{type}}</th>
</tr>
{{#if description}}
<tr>
<th>description</th>
<th colspan="2">{{description}}</th>
</tr>
{{/if}}
{{#if name}}
<tr>
<th>name</th>
<th colspan="2">{{name}}</th>
</tr>
{{/if}}
{{#if in}}
<tr>
<th>in</th>
<th colspan="2">{{in}}</th>
</tr>
{{/if}}
</table>
{{/ifeq}}
{{#ifeq type "basic"}}
<table>
<tr>
<th>type</th>
<th colspan="2">{{type}}</th>
</tr>
{{#if description}}
<tr>
<th>description</th>
<th colspan="2">{{description}}</th>
</tr>
{{/if}}
</table>
{{/ifeq}}
{{/this}}
{{/each}}

View File

@@ -0,0 +1,49 @@
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/3.0.1/github-markdown.min.css"/>
<style>
.markdown-body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
}
@media (max-width: 767px) {
.markdown-body {
padding: 15px;
}
}
.markdown-body table {
display: table;
}
</style>
<!-- JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.0/showdown.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/JanLoebel/showdown-toc/src/showdown-toc.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
var markdown = document.querySelector('noscript').innerText
var converter = new showdown.Converter({emoji: true, extensions: ['toc']})
converter.setFlavor('github')
var html = converter.makeHtml(markdown)
document.body.innerHTML = html
})
</script>
<title>{{info.title}} {{info.version}}</title>
</head>
<body class="markdown-body">
<noscript>{{>markdown}}</noscript>
</body>
</html>