mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
changes to make script processes in api better
This commit is contained in:
@ -102,6 +102,8 @@ public class ScriptsMetaDataProvider
|
||||
{
|
||||
return (new QProcessMetaData()
|
||||
.withName(STORE_SCRIPT_REVISION_PROCESS_NAME)
|
||||
.withTableName(Script.TABLE_NAME)
|
||||
.withIsHidden(true)
|
||||
.withStepList(List.of(
|
||||
new QBackendStepMetaData()
|
||||
.withName("main")
|
||||
@ -118,6 +120,8 @@ public class ScriptsMetaDataProvider
|
||||
{
|
||||
return (new QProcessMetaData()
|
||||
.withName(TEST_SCRIPT_PROCESS_NAME)
|
||||
.withTableName(Script.TABLE_NAME)
|
||||
.withIsHidden(true)
|
||||
.withStepList(List.of(
|
||||
new QBackendStepMetaData()
|
||||
.withName("main")
|
||||
|
@ -202,8 +202,8 @@ public class GenerateOpenApiSpecAction extends AbstractQActionFunction<GenerateO
|
||||
*******************************************************************************/
|
||||
public GenerateOpenApiSpecOutput execute(GenerateOpenApiSpecInput input) throws QException
|
||||
{
|
||||
QInstance qInstance = QContext.getQInstance();
|
||||
String version = input.getVersion();
|
||||
QInstance qInstance = QContext.getQInstance();
|
||||
String version = input.getVersion();
|
||||
|
||||
ApiInstanceMetaDataContainer apiInstanceMetaDataContainer = ApiInstanceMetaDataContainer.of(qInstance);
|
||||
if(apiInstanceMetaDataContainer == null)
|
||||
@ -1052,7 +1052,7 @@ public class GenerateOpenApiSpecAction extends AbstractQActionFunction<GenerateO
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
private static Parameter processFieldToParameter(ApiInstanceMetaData apiInstanceMetaData, QFieldMetaData field)
|
||||
private Parameter processFieldToParameter(ApiInstanceMetaData apiInstanceMetaData, QFieldMetaData field)
|
||||
{
|
||||
ApiFieldMetaDataContainer apiFieldMetaDataContainer = ApiFieldMetaDataContainer.ofOrNew(field);
|
||||
ApiFieldMetaData apiFieldMetaData = apiFieldMetaDataContainer.getApiFieldMetaData(apiInstanceMetaData.getName());
|
||||
@ -1062,16 +1062,14 @@ public class GenerateOpenApiSpecAction extends AbstractQActionFunction<GenerateO
|
||||
{
|
||||
description += " Default value is " + field.getDefaultValue() + ", if not given.";
|
||||
}
|
||||
if(apiFieldMetaData != null && StringUtils.hasContent(apiFieldMetaData.getDescription()))
|
||||
{
|
||||
description = apiFieldMetaData.getDescription();
|
||||
}
|
||||
|
||||
Schema fieldSchema = getFieldSchema(field, description, apiInstanceMetaData);
|
||||
|
||||
Parameter parameter = new Parameter()
|
||||
.withName(field.getName())
|
||||
.withDescription(description)
|
||||
.withRequired(field.getIsRequired())
|
||||
.withSchema(new Schema().withType(getFieldType(field)));
|
||||
.withSchema(fieldSchema);
|
||||
|
||||
if(apiFieldMetaData != null)
|
||||
{
|
||||
@ -1183,7 +1181,14 @@ public class GenerateOpenApiSpecAction extends AbstractQActionFunction<GenerateO
|
||||
|
||||
for(QFieldMetaData field : tableApiFields)
|
||||
{
|
||||
Schema fieldSchema = getFieldSchema(table, field);
|
||||
String fieldLabel = field.getLabel();
|
||||
if(!StringUtils.hasContent(fieldLabel))
|
||||
{
|
||||
fieldLabel = QInstanceEnricher.nameToLabel(field.getName());
|
||||
}
|
||||
|
||||
String defaultDescription = fieldLabel + " for the " + table.getLabel() + ".";
|
||||
Schema fieldSchema = getFieldSchema(field, defaultDescription, apiInstanceMetaData);
|
||||
tableFields.put(ApiFieldMetaData.getEffectiveApiFieldName(apiInstanceMetaData.getName(), field), fieldSchema);
|
||||
}
|
||||
|
||||
@ -1354,20 +1359,22 @@ public class GenerateOpenApiSpecAction extends AbstractQActionFunction<GenerateO
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
private Schema getFieldSchema(QTableMetaData table, QFieldMetaData field)
|
||||
private Schema getFieldSchema(QFieldMetaData field, String defaultDescription, ApiInstanceMetaData apiInstanceMetaData)
|
||||
{
|
||||
String fieldLabel = field.getLabel();
|
||||
if(!StringUtils.hasContent(fieldLabel))
|
||||
{
|
||||
fieldLabel = QInstanceEnricher.nameToLabel(field.getName());
|
||||
}
|
||||
ApiFieldMetaDataContainer apiFieldMetaDataContainer = ApiFieldMetaDataContainer.ofOrNew(field);
|
||||
ApiFieldMetaData apiFieldMetaData = apiFieldMetaDataContainer.getApiFieldMetaData(apiInstanceMetaData.getName());
|
||||
|
||||
String description = fieldLabel + " for the " + table.getLabel() + ".";
|
||||
String description = defaultDescription;
|
||||
if(field.getType().equals(QFieldType.BLOB))
|
||||
{
|
||||
description = "Base64 encoded " + description;
|
||||
}
|
||||
|
||||
if(apiFieldMetaData != null && StringUtils.hasContent(apiFieldMetaData.getDescription()))
|
||||
{
|
||||
description = apiFieldMetaData.getDescription();
|
||||
}
|
||||
|
||||
Schema fieldSchema = new Schema()
|
||||
.withType(getFieldType(field))
|
||||
.withFormat(getFieldFormat(field))
|
||||
|
@ -52,6 +52,7 @@ public class ApiProcessMetaData
|
||||
|
||||
private String apiProcessName;
|
||||
private Boolean isExcluded;
|
||||
private Boolean overrideProcessIsHidden;
|
||||
|
||||
private String path;
|
||||
private HttpMethod method;
|
||||
@ -577,4 +578,35 @@ public class ApiProcessMetaData
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for overrideProcessIsHidden
|
||||
*******************************************************************************/
|
||||
public Boolean getOverrideProcessIsHidden()
|
||||
{
|
||||
return (this.overrideProcessIsHidden);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for overrideProcessIsHidden
|
||||
*******************************************************************************/
|
||||
public void setOverrideProcessIsHidden(Boolean overrideProcessIsHidden)
|
||||
{
|
||||
this.overrideProcessIsHidden = overrideProcessIsHidden;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for overrideProcessIsHidden
|
||||
*******************************************************************************/
|
||||
public ApiProcessMetaData withOverrideProcessIsHidden(Boolean overrideProcessIsHidden)
|
||||
{
|
||||
this.overrideProcessIsHidden = overrideProcessIsHidden;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -68,12 +68,6 @@ public class ApiProcessUtils
|
||||
throw (new QNotFoundException("Could not find a process named " + processApiName + " in this api."));
|
||||
}
|
||||
|
||||
if(BooleanUtils.isTrue(process.getIsHidden()))
|
||||
{
|
||||
LOG.info("404 because process isHidden", logPairs);
|
||||
throw (new QNotFoundException("Could not find a process named " + processApiName + " in this api."));
|
||||
}
|
||||
|
||||
ApiProcessMetaDataContainer apiProcessMetaDataContainer = ApiProcessMetaDataContainer.of(process);
|
||||
if(apiProcessMetaDataContainer == null)
|
||||
{
|
||||
@ -94,6 +88,15 @@ public class ApiProcessUtils
|
||||
throw (new QNotFoundException("Could not find a process named " + processApiName + " in this api."));
|
||||
}
|
||||
|
||||
if(BooleanUtils.isTrue(process.getIsHidden()))
|
||||
{
|
||||
if(!BooleanUtils.isTrue(apiProcessMetaData.getOverrideProcessIsHidden()))
|
||||
{
|
||||
LOG.info("404 because process isHidden", logPairs);
|
||||
throw (new QNotFoundException("Could not find a process named " + processApiName + " in this api."));
|
||||
}
|
||||
}
|
||||
|
||||
APIVersion requestApiVersion = new APIVersion(version);
|
||||
List<APIVersion> supportedVersions = apiInstanceMetaData.getSupportedVersions();
|
||||
if(CollectionUtils.nullSafeIsEmpty(supportedVersions) || !supportedVersions.contains(requestApiVersion))
|
||||
|
Reference in New Issue
Block a user