Skip to content

Commit

Permalink
feat:fix #564,change string to defaultPrimitive;change format int32 t…
Browse files Browse the repository at this point in the history
…o opentype
  • Loading branch information
lixingzhi committed Sep 10, 2023
1 parent c0ac021 commit fae4970
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public static Map<String, Object> buildParametersSchema(ApiReqParam header) {
Map<String, Object> schema = new HashMap<>(10);
String openApiType = DocUtil.javaTypeToOpenApiTypeConvert(header.getType());
schema.put("type", openApiType);
schema.put("format", "int16".equals(header.getType()) ? "int32" : header.getType());
schema.put("format", openApiType);
return schema;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ Map<String, Object> getStringParams(ApiParam apiParam, boolean hasItems) {
public Map<String, Object> buildComponentsSchema(List<ApiDoc> apiDocs) {
Map<String, Object> schemas = new HashMap<>(4);
Map<String, Object> component = new HashMap<>();
component.put("string", STRING_COMPONENT);
component.put(DEFAULT_PRIMITIVE, STRING_COMPONENT);
apiDocs.forEach(
a -> {
List<ApiMethodDoc> apiMethodDocs = a.getList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ Map<String, Object> getStringParams(ApiParam apiParam, boolean hasItems) {
@Override
public Map<String, Object> buildComponentsSchema(List<ApiDoc> apiDocs) {
Map<String, Object> component = new HashMap<>();
component.put("string", STRING_COMPONENT);
component.put(DEFAULT_PRIMITIVE, STRING_COMPONENT);
apiDocs.forEach(
a -> {
List<ApiMethodDoc> apiMethodDocs = a.getList();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/power/doc/constants/DocGlobalConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,6 @@ public interface DocGlobalConstants {
String DEFAULT_FILTER_METHOD = "*";

String JAR_TEMP = "./smart-temp/";

String DEFAULT_PRIMITIVE = "defaultPrimitive";
}
3 changes: 2 additions & 1 deletion src/main/java/com/power/doc/utils/OpenApiSchemaUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import com.power.common.util.CollectionUtil;
import com.power.common.util.StringUtil;
import com.power.doc.constants.DocGlobalConstants;
import com.power.doc.model.ApiParam;

/**
Expand Down Expand Up @@ -86,7 +87,7 @@ public static String getClassNameFromParams(List<ApiParam> apiParams, String suf
if (CollectionUtil.isNotEmpty(apiParams) && apiParams.size() == 1
&& StringUtil.isEmpty(apiParams.get(0).getClassName())
&& CollectionUtil.isEmpty(apiParams.get(0).getChildren())) {
return "string";
return DocGlobalConstants.DEFAULT_PRIMITIVE;
}
for (ApiParam a : apiParams) {
if (StringUtil.isNotEmpty(a.getClassName())) {
Expand Down

0 comments on commit fae4970

Please sign in to comment.