Skip to content

Commit

Permalink
fix: added missing filter for hook imports for native types
Browse files Browse the repository at this point in the history
  • Loading branch information
melistik committed Mar 21, 2023
1 parent 8e12f22 commit 0c4569b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public List<OpenApiController> getControllers(HttpServletRequest request) {
addOperation(remapped, PathItem.HttpMethod.DELETE, entry.getKey(), entry.getValue().getDelete());
addOperation(remapped, PathItem.HttpMethod.PATCH, entry.getKey(), entry.getValue().getPatch());
}
return remapped.entrySet().stream().map(e -> new OpenApiController(e.getKey(), e.getValue())).collect(Collectors.toList());
return remapped.entrySet().stream().map(e -> new OpenApiController(e.getKey(), e.getValue(), typescriptConverter)).collect(Collectors.toList());
}

public void getTypescriptClients(ReactQueryVersion reactQueryVersion, HttpServletRequest request, HttpServletResponse response, String baseUrl, String groupName, String filename) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package io.rocketbase.commons.openapi.model;

import io.rocketbase.commons.openapi.OpenApiControllerMethodExtraction;
import io.rocketbase.commons.openapi.OpenApiConverter;
import io.rocketbase.commons.util.Nulls;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand All @@ -19,17 +21,20 @@ public class OpenApiController implements Serializable {
private String controllerBean;
private List<OpenApiControllerMethodExtraction> methods;

private OpenApiConverter openApiConverter;

public String getShortName() {
return controllerBean.substring(controllerBean.lastIndexOf(".") + 1).replace("Controller", "");
}

public OpenApiController(String controllerBean, List<OpenApiControllerMethodExtraction> methods) {
public OpenApiController(String controllerBean, List<OpenApiControllerMethodExtraction> methods, OpenApiConverter openApiConverter) {
this.controllerBean = controllerBean;
this.methods = methods;
// link this controller to methods
for (OpenApiControllerMethodExtraction m : methods) {
m.setController(this);
}
this.openApiConverter = openApiConverter;
}

public Set<String> getImportTypes() {
Expand All @@ -52,6 +57,8 @@ protected String toKebabCase(String input) {
public Set<String> getFieldImports() {
return methods.stream().filter(m -> m.hasOptionalFields() || m.hasRequiredFields())
.map(OpenApiControllerMethodExtraction::getShortInputType)
.filter(v -> !Nulls.notNull(openApiConverter, OpenApiConverter::getNativeTypes, Collections.emptySet())
.contains(v.toLowerCase()))
.collect(Collectors.toSet());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,12 @@ ResponseEntity<PageableResult<Activity>> loadActivities(@ParameterObject
)
ResponseEntity<Activity> findById(@PathVariable("id") String id);

@GetMapping(
path = "/hosted/{id}",
produces = MimeTypeUtils.APPLICATION_JSON_VALUE,
consumes = MimeTypeUtils.ALL_VALUE
)
ResponseEntity<Activity> findByHosted(@PathVariable("id") String id);


}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ public ResponseEntity<PageableResult<Activity>> loadActivities(Pageable pageable
public ResponseEntity<Activity> findById(String id) {
return null;
}

@Override
public ResponseEntity<Activity> findByHosted(String id) {
return null;
}
}

0 comments on commit 0c4569b

Please sign in to comment.