Skip to content

Commit

Permalink
feat: try to solve some springdoc issue with paths + schema convertes
Browse files Browse the repository at this point in the history
  • Loading branch information
melistik committed Aug 28, 2024
1 parent 86ac947 commit 8fc801b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public void downloadZip() throws Exception {
log.info("downloaded: {}", destination.getAbsolutePath());
}

@Test
public void downloadOpenApiYaml() throws Exception {
File destination = new File("target/api-docs.yaml");
download(new URL(baseUrl + "/v3/api-docs.yaml"), destination);
log.info("downloaded: {}", destination.getAbsolutePath());
}

private static void download(URL url, File file) throws IOException {
ReadableByteChannel rbc = Channels.newChannel(url.openStream());
FileOutputStream fos = new FileOutputStream(file);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.rocketbase.commons.openapi.sample.dto;

import io.hypersistence.tsid.TSID;
import lombok.*;

import java.io.Serializable;
Expand All @@ -12,7 +13,7 @@
@Data
public class Tile implements Serializable {

private String id;
private TSID id;

private TileType type;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.rocketbase.commons.openapi.sample.resource;

import io.hypersistence.tsid.TSID;
import io.rocketbase.commons.dto.PageableResult;
import io.rocketbase.commons.generator.InfiniteHook;
import io.rocketbase.commons.generator.QueryHook;
Expand Down Expand Up @@ -54,5 +55,5 @@ ResponseEntity<PageableResult<Tile>> loadTiles(@ParameterObject
consumes = MimeTypeUtils.ALL_VALUE
)
Tile get(@Parameter(description = "id of tile", required = true)
@PathVariable("id") String id);
@PathVariable("id") TSID id);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.rocketbase.commons.openapi.sample.resource;

import io.hypersistence.tsid.TSID;
import io.rocketbase.commons.dto.PageableResult;
import io.rocketbase.commons.openapi.sample.dto.Tile;
import io.rocketbase.commons.openapi.sample.dto.UserPreference;
Expand All @@ -19,7 +20,7 @@ public ResponseEntity<PageableResult<Tile>> loadTiles(Pageable pageable, Optiona
}

@Override
public Tile get(String id) {
public Tile get(TSID id) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import io.hypersistence.tsid.TSID;
import io.rocketbase.commons.controller.exceptionhandler.TsidDecodeExceptionHandler;
import io.rocketbase.commons.exception.TsidDecodeException;
import io.rocketbase.commons.tsid.TsidConverter;
import io.rocketbase.commons.tsid.TsidModule;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.Formatter;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.WebDataBinder;
Expand All @@ -36,6 +38,11 @@ public Module tsidModule() {
return new TsidModule();
}

@Bean
public Converter tsidConverter() {
return new TsidConverter();
}

@RestControllerAdvice
public static class Advice {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.rocketbase.commons.tsid;

import io.hypersistence.tsid.TSID;
import org.springframework.core.convert.converter.Converter;
import org.springframework.lang.Nullable;

public class TsidConverter implements Converter<String, TSID> {

@Nullable
@Override
public TSID convert(String value) {
return TSID.isValid(value) ? TSID.from(value) : null;
}
}

0 comments on commit 8fc801b

Please sign in to comment.