I can’t generate the models / controllers / services in any way, I run this command mvn clean install but it generates the files in target/generate-sources,I have used json but also yaml, How can I make this generate it for me in src/main?
Here is my pom.xml , project – https://github.com/FreeTrainingZone/identityverification-repo
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.6.4</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.freetrainingzone</groupId> <artifactId>identityverification </artifactId> <version>0.0.1-SNAPSHOT</version> <name>identityverification </name> <description>Identity Verification REST API</description> <properties> <java.version>17</java.version> <reqjson.file>${project.basedir}/src/main/resources/identityverificationservice.json</reqjson.file> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>2.0.1.Final</version> </dependency> <dependency> <groupId>javax.annotation</groupId> <artifactId>javax.annotation-api</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.13.2</version> </dependency> <dependency> <groupId>io.swagger.core.v3</groupId> <artifactId>swagger-annotations</artifactId> <version>2.1.13</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>io.swagger.codegen.v3</groupId> <artifactId>swagger-codegen-maven-plugin</artifactId> <version>3.0.33</version> <dependencies> <dependency> <groupId>com.github.jknack</groupId> <artifactId>handlebars</artifactId> <version>4.3.0</version> </dependency> </dependencies> <executions> <execution> <id>request-service</id> <!-- <goals> <goal>generate</goal> </goals> --> <configuration> <inputSpec>${reqjson.file}</inputSpec> <artifactId>contract-service</artifactId> <output>${project.basedir}/target/generated-sources/swagger</output> <language>spring</language> <generateApis>true</generateApis> <generateModels>true</generateModels> <modelPackage>com.freetrainingzone.identityverification.model</modelPackage> <apiPackage>com.freetrainingzone.identityverification.controller.api</apiPackage> <generateSupportingFiles>false</generateSupportingFiles> <configOptions> <interfaceOnly>false</interfaceOnly> <library>spring-boot</library> <singleContentTypes>true</singleContentTypes> <sourceFolder>/</sourceFolder> <dateLibrary>java17</dateLibrary> </configOptions> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>
Advertisement
Answer
Modify file gradle/swagger.gradle
openApiGenerate { outputDir = "$rootDir".toString()
Modify file pom.xml
<configuration> <output>${project.basedir}/src/main</output>