我正在尝试为OpenApi 3.0.2规范锻炼生成的服务器端Spring MVC代码。
这就是“路径”之一的样子:-
paths:
/api/v1/int/integrations/{some-path-variable}/some-action:
get:
summary: Summary
description: How to change the generated Api/Controller class name?
operationId: methodName
tags:
- inventory
parameters:
- name: Authorization
other details....
使用Maven插件生成服务器端代码,该插件配置为:-
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.1.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/open-api/myapi.yaml</inputSpec>
<generatorName>spring</generatorName>
<library>spring-boot</library>
<output>${project.build.directory}/generated-openapi/spring</output>
<generateApis>true</generateApis>
<addCompileSourceRoot>true</addCompileSourceRoot>
<artifactVersion>${project.version}</artifactVersion>
<groupId>com.company.division</groupId>
<artifactId>myapi-api</artifactId>
<generateApiTests>true</generateApiTests>
<modelPackage>com.company.division.myapi.generated.model</modelPackage>
<apiPackage>com.company.division.myapi.generated.api</apiPackage>
<generateApiDocumentation>true</generateApiDocumentation>
<configOptions>
<dateLibrary>java8</dateLibrary>
<java8>true</java8>
<interfaceOnly>true</interfaceOnly>
<reactive>false</reactive>
<useBeanValidation>true</useBeanValidation>
<performBeanValidation>true</performBeanValidation>
<useOptional>false</useOptional>
<serviceInterface>true</serviceInterface>
<serviceImplementation>false</serviceImplementation>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
从插件配置中可以看出,我只对生成模型类和Spring Controller Interfaces / API接口很感兴趣。
问题
对于所提到的OpenAPI规范,生成的MVC控制器接口被命名为ApiApi
。我猜这是从路径的开始部分得出的。我可以摆脱/api/v1/int
部分,但是会生成名为IntegrationsApi
的接口,但我不想将其命名为InventoryApi
。
我们必须选择什么选项来控制生成的控制器接口?
答案 0 :(得分:1)
“ useTags”创建接口和控制器类名
在插件配置中设置#include<stdio.h>
#include<stdlib.h>
void print_list(int *arr,int *size,int *capacity)
{
printf("capacity = %d; size = %d; elements = ",*capacity,*size);
for(int i=0;i<(*size);i++){
printf("%d ",arr[i]);
}
printf("\n");
}
int * push_back(int *arr,int data,int *size,int *capacity)
{
int *b;
if(*size == *capacity){
*capacity = 2*(*capacity);
b = (int *)malloc(sizeof(int)*(*capacity));
for(int i=0;i<(*size);i++){
b[i]= arr[i];
}
b[*size]=data;
*size=*size+1;
print_list(b,size,capacity);
return b;
}
arr[*size]=data;
*size=*size+1;
print_list(arr,size,capacity);
return arr;
}
int main()
{
int size=0;
int n;
int x;
int *arr;
arr = (int *) malloc(sizeof(int));
int capacity=1;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&x);
arr=push_back(arr,x,&size,&capacity);
}
}
configOption解决了我的问题:-
df_Conversion = pd.DataFrame(columns = ['Ab','Unit of Measure', 'Conversion', 'Net/Gross Weight (lbs)', 'Volume (cubic ft)', 'Shipping Dimensions (inch) L x W x H', 'GTIN'])
myList = ['ZOL890080401','ZOL89004004','ZOL89000180','ZOL3502111001','ZOL21110201CC','ZIM750000300','ZIM607500007','ZIM515047501','ZIM387400300','ZIM197800100','ZIM160201000','ZIM160200500','ZIG2516','ZIG1934S','ZIG1933S','ZIG1925S','XOM8229506','WTLSS1','WTLSB2','WTLRHS001','WTLOS1','WTLERSHLFM','WTLDIVAJ6','WSD909165','WOL7507040','WOL7507030','WOL7505730','WOL66084LW40','WOL66083LW40','WOL66083LW30']
unspsc_link = []
for i in myList:
unspsc_link.append(f"https://www.medline.com/sku/item/MDP{i}")
link = requests.get(unspsc_link).text
while True:
soup = BeautifulSoup(link, 'lxml')
SKUDATA = []
div1 = soup.find('div', {'class': 'medSKUPriceData'})
SKUDATA.append(div1.text.strip())
div = soup.find('div', {'class': 'medSKUFltRt'})
right_table3 = div.find('table', {'class': 'medSKUTableDetails table-striped uomTable'})
df3 = pd.read_html(str(right_table3))[0]
df2 = pd.DataFrame(SKUDATA)
df_ProductId = pd.DataFrame()
df_ProductId = df_ProductId.append(df2, ignore_index = True)
df_ProductId.columns = ['Ab']
df_Unit_of_Measurment = pd.DataFrame(columns=['Unit of Measure', 'Conversion', 'Net/Gross Weight (lbs)', 'Volume (cubic ft)', 'Shipping Dimensions (inch) L x W x H', 'GTIN'])
df_Unit_of_Measurment = df_Unit_of_Measurment.append(df3, ignore_index = True)
df_Unit_of_Measurment.columns = ['Unit of Measure', 'Conversion', 'Net/Gross Weight (lbs)', 'Volume (cubic ft)', 'Shipping Dimensions (inch) L x W x H', 'GTIN']
df_y = pd.DataFrame()
df_y = pd.concat([df_ProductId,df_Unit_of_Measurment], ignore_index=True)
df_y = df_y.fillna(method='ffill')
df_y = df_y[1:]
df_Conversion = df_Conversion.append(df_y, ignore_index = True)
df_Conversion = df_Conversion[1:]