Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
- implementa Projected on script routes
- ref #3853
  • Loading branch information
jknack committed Feb 28, 2026
commit db563bfac036ded4bba802f1390a429ac14c5aeb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.jooby.Router;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.security.SecurityScheme;

Expand All @@ -39,12 +40,24 @@ public void setSource(String classname) {
}

public void addSecuritySchemes(String name, SecurityScheme scheme) {
var components = getComponents();
if (components == null) {
components = new Components();
setComponents(components);
getRequiredComponents().addSecuritySchemes(name, scheme);
}

@JsonIgnore
public Components getRequiredComponents() {
if (getComponents() == null) {
setComponents(new Components());
}
return getComponents();
}

@JsonIgnore
public Map<String, Schema> getRequiredSchemas() {
var components = getRequiredComponents();
if (components.getSchemas() == null) {
components.setSchemas(new LinkedHashMap<>());
}
components.addSecuritySchemes(name, scheme);
return components.getSchemas();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,9 @@ public OperationExt copy(String pattern) {
public String getPath(Map<String, Object> pathParams) {
return Router.reverse(getPath(), pathParams);
}

@JsonIgnore
public boolean isScript() {
return getController() == null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.type.SimpleType;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import io.jooby.Context;
import io.jooby.FileUpload;
import io.jooby.SneakyThrows;
import io.jooby.StatusCode;
import io.jooby.*;
import io.jooby.internal.openapi.javadoc.JavaDocParser;
import io.jooby.openapi.DebugOption;
import io.swagger.v3.core.util.RefUtils;
Expand Down Expand Up @@ -172,6 +169,9 @@ public Schema schema(Class type) {
if (isVoid(type.getName())) {
return null;
}
if (type == Projected.class) {
return new ObjectSchema().name("Projected");
}
if (type == String.class) {
return new StringSchema();
}
Expand Down Expand Up @@ -496,6 +496,13 @@ public MethodNode findMethodNode(Type type, String name) {
.orElseThrow(() -> new IllegalArgumentException("Method not found: " + type + "." + name));
}

public MethodNode findMethodNode(Type type, String name, String desc) {
return nodes.computeIfAbsent(type, this::newClassNode).methods.stream()
.filter(it -> it.name.equals(name) && it.desc.equals(desc))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("Method not found: " + type + "." + name));
}

public ClassNode classNodeOrNull(Type type) {
try {
return nodes.computeIfAbsent(type, this::newClassNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private String patternToOperationId(String pattern) {
return "";
}
return Stream.of(pattern.split("\\W+"))
.filter(s -> s.length() > 0)
.filter(s -> !s.isEmpty())
.map(
segment ->
Character.toUpperCase(segment.charAt(0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,8 @@ public Map<String, Object> getGlobalVariables() {
.toList();
openapiRoot.put("tags", tags);
// Schemas
var components = context.openapi.getComponents();
if (components != null && components.getSchemas() != null) {
var schemas = components.getSchemas();
openapiRoot.put("schemas", new ArrayList<>(schemas.values()));
}
var schemas = context.openapi.getRequiredSchemas();
openapiRoot.put("schemas", new ArrayList<>(schemas.values()));

// make in to work without literal
openapiRoot.put("query", "query");
Expand Down Expand Up @@ -466,9 +463,6 @@ public Schema<?> resolveSchema(String path) {

private Optional<Schema<?>> resolveSchemaInternal(String name) {
var components = openapi.getComponents();
if (components == null || components.getSchemas() == null) {
throw new NoSuchElementException("No schema found");
}
if (name.startsWith(COMPONENTS_SCHEMAS_REF)) {
name = name.substring(COMPONENTS_SCHEMAS_REF.length());
}
Expand Down
Loading