Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
import modelengine.fel.tool.info.entity.ReturnPropertyEntity;
import modelengine.fel.tool.info.entity.SchemaEntity;
import modelengine.fitframework.annotation.Property;
import modelengine.fitframework.util.StringUtils;

import net.bytebuddy.description.annotation.AnnotationDescription;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.method.ParameterDescription;

import static modelengine.fitframework.inspection.Validation.notNull;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -78,9 +79,7 @@ private static Map<String, Object> getStringObjectMap(ReturnPropertyEntity retur
if (returnPropertyEntity.getConvertor() != null) {
returnProperty.put("convertor", returnPropertyEntity.getConvertor());
}
if (StringUtils.isNotBlank(returnPropertyEntity.getExample())) {
returnProperty.put("example", returnPropertyEntity.getExample());
}
returnProperty.put("examples", returnPropertyEntity.getExamples());
return returnProperty;
}

Expand Down Expand Up @@ -115,7 +114,7 @@ private static PropertyEntity parseProperty(ParameterDescription parameterDescri
entity.setDescription(property.description());
entity.setNeed(property.required());
entity.setDefaultValue(property.defaultValue());
entity.setExample(property.example());
entity.setExamples(Collections.singletonList(property.example()));
}
return entity;
}
Expand All @@ -128,7 +127,7 @@ private static ReturnPropertyEntity parseReturnProperty(MethodDescription method
Property property = returnAnnotation.load();
returnPropertyEntity.setName(property.name());
returnPropertyEntity.setDescription(property.description());
returnPropertyEntity.setExample(property.example());
returnPropertyEntity.setExamples(Collections.singletonList(property.example()));
}
notNull(methodDescription.getReturnType(), "The return type cannot be null.");
JsonNode jsonNode = JacksonTypeParser.getParameterSchema(methodDescription.getReturnType());
Expand All @@ -153,6 +152,8 @@ private static void setPropertyType(PropertyEntity returnPropertyEntity, JsonNod
List<String> requiredFields = new LinkedList<>();
jsonNode.get("properties").fieldNames().forEachRemaining(requiredFields::add);
returnPropertyEntity.setRequired(requiredFields);
} else {
returnPropertyEntity.setProperties(new ArrayList<>());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package modelengine.fel.maven.compile.parser.weather;

import modelengine.fel.maven.compile.parser.weather.dto.RainPosition;
import modelengine.fel.tool.annotation.Group;
import modelengine.fel.tool.annotation.ToolMethod;
import modelengine.fitframework.annotation.Genericable;
Expand All @@ -31,8 +32,10 @@ public interface Rain {
*/
@ToolMethod(name = "rain_today", description = "该方法获取今天的下雨信息")
@Genericable("genericable_weather_rain_today")
String today(@Property(description = "查询地点", required = true) String location,
@Property(description = "查询日期", required = true) Date date);
String today(@Property(description = "查询地点", required = true, example = "Hangzhou") String location,
@Property(description = "查询日期", required = true) Date date,
@Property(description = "下雨的经纬度") RainPosition rainPosition,
@Property(description = "其他信息") Object info);

/**
* 获取明天下雨信息的结果。
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
* This file is a part of the ModelEngine Project.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

package modelengine.fel.maven.compile.parser.weather.dto;

/**
* 添加测试用的工具的自定义结构体。
*
* @author 杭潇
* @since 2025-07-21
*/
public class RainPosition {
/**
* 表示下雨位置的经度值的 {@link String}。
*/
String latitude;

/**
* 表示下雨位置的纬度值的 {@link String}。
*/
String longitude;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package modelengine.fel.maven.compile.parser.weather.impl;

import modelengine.fel.maven.compile.parser.weather.dto.RainPosition;
import modelengine.fel.tool.annotation.Attribute;
import modelengine.fel.tool.annotation.Group;
import modelengine.fel.tool.annotation.ToolMethod;
Expand Down Expand Up @@ -34,7 +35,7 @@ public class CityARainImpl implements Rain {
})
@Property(description = "获取今日下雨信息的结果")
@Override
public String today(String location, Date date) {
public String today(String location, Date date, RainPosition rainPosition, Object info) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package modelengine.fel.maven.compile.parser.weather.impl;

import modelengine.fel.maven.compile.parser.weather.dto.RainPosition;
import modelengine.fel.tool.annotation.Attribute;
import modelengine.fel.tool.annotation.Group;
import modelengine.fel.tool.annotation.ToolMethod;
Expand All @@ -30,7 +31,7 @@ public class CityBRainImpl implements Rain {
@Attribute(key = "tags", value = "FIT"), @Attribute(key = "tags", value = "TEST")
})
@Override
public String today(String location, Date date) {
public String today(String location, Date date, RainPosition rainPosition, Object info) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,47 @@
"type" : "object",
"properties" : {
"location" : {
"defaultValue" : "",
"description" : "查询地点",
"name" : "location",
"type" : "string",
"example" : ""
"examples" : [ "Hangzhou" ],
"default" : ""
},
"date" : {
"defaultValue" : "",
"description" : "查询日期",
"name" : "date",
"type" : "string",
"example" : ""
"examples" : [ "" ],
"default" : ""
},
"rainPosition" : {
"description" : "下雨的经纬度",
"name" : "rainPosition",
"type" : "object",
"properties" : {
"latitude" : {
"type" : "string"
},
"longitude" : {
"type" : "string"
}
},
"examples" : [ "" ],
"required" : [ "latitude", "longitude" ],
"default" : ""
},
"info" : {
"description" : "其他信息",
"name" : "info",
"type" : "object",
"properties" : [ ],
"examples" : [ "" ],
"default" : ""
}
},
"required" : [ "location", "date" ]
},
"order" : [ "location", "date" ],
"order" : [ "location", "date", "rainPosition", "info" ],
"return" : {
"type" : "string",
"convertor" : ""
Expand Down Expand Up @@ -85,16 +109,35 @@
"date" : {
"name" : "date",
"type" : "string"
},
"rainPosition" : {
"name" : "rainPosition",
"type" : "object",
"properties" : {
"latitude" : {
"type" : "string"
},
"longitude" : {
"type" : "string"
}
},
"required" : [ "latitude", "longitude" ]
},
"info" : {
"name" : "info",
"type" : "object",
"properties" : [ ]
}
},
"required" : [ ]
},
"order" : [ "location", "date" ],
"order" : [ "location", "date", "rainPosition", "info" ],
"return" : {
"name" : "",
"description" : "获取今日下雨信息的结果",
"type" : "string",
"convertor" : ""
"convertor" : "",
"examples" : [ "" ]
}
},
"runnables" : {
Expand Down Expand Up @@ -131,7 +174,8 @@
"name" : "",
"description" : "获取明日下雨信息的结果",
"type" : "string",
"convertor" : ""
"convertor" : "",
"examples" : [ "" ]
}
},
"runnables" : {
Expand Down Expand Up @@ -166,11 +210,29 @@
"date" : {
"name" : "date",
"type" : "string"
},
"rainPosition" : {
"name" : "rainPosition",
"type" : "object",
"properties" : {
"latitude" : {
"type" : "string"
},
"longitude" : {
"type" : "string"
}
},
"required" : [ "latitude", "longitude" ]
},
"info" : {
"name" : "info",
"type" : "object",
"properties" : [ ]
}
},
"required" : [ ]
},
"order" : [ "location", "date" ],
"order" : [ "location", "date", "rainPosition", "info" ],
"return" : {
"type" : "string",
"convertor" : ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package modelengine.fel.tool.info.entity;

import modelengine.fitframework.annotation.Property;

import java.util.List;

/**
Expand All @@ -16,13 +18,14 @@
* @since 2024-10-26
*/
public class PropertyEntity {
@Property(name = "default")
private String defaultValue;
private String description;
private String name;
private String type;
private Object items;
private Object properties;
private String example;
private List<String> examples;
private List<String> required;
private transient boolean need;

Expand Down Expand Up @@ -173,18 +176,18 @@ public void setProperties(Object properties) {
/**
* 获取参数的示例值。
*
* @return 表示参数的示例值的 {@link String}。
* @return 表示参数的示例值的 {@link List}{@code <}{@link String}{@code >}。
*/
public String getExample() {
return this.example;
public List<String> getExamples() {
return this.examples;
}

/**
* 设置参数的示例值。
*
* @param example 表示参数的示例值的 {@link String}。
* @param examples 表示参数的示例值的 {@link List}{@code <}{@link String}{@code >}。
*/
public void setExample(String example) {
this.example = example;
public void setExamples(List<String> examples) {
this.examples = examples;
}
}