ããã«ã¡ã¯ãã¨ããµã¤ãæ ªå¼ä¼ç¤¾ã®å¹³ç³ã§ãã
ä»åã¯ãOpenAPI Generatorãå©ç¨ãã¦èªåçæããJavaã®APIã¯ã©ã¤ã¢ã³ããç¬èªã®ãã¼ã«ã«ãªãã¸ããªã«ä¿åããæ¹æ³ããç´¹ä»ãã¾ãã
ãªããä»åã®æ¹æ³ã¯ä¾ã¨ãã¦ãOpenAPI Generatorãå©ç¨ãã¦èªåçæããJavaã®APIã¯ã©ã¤ã¢ã³ãããæãã¦ããã ãã§ããã以å¤ã®èªä½ã®ã©ã¤ãã©ãªçã§ãå©ç¨ã§ãã¾ãã
ã¯ããã«
OpenAPI Generatorãå©ç¨ãã¦Javaã®APIã¯ã©ã¤ã¢ã³ããèªåçæããåºç¤ã«ã¤ãã¦ã¯ã以ä¸ã®ããã°è¨äºã§ã¾ã¨ãã¦ãã¾ãã®ã§ããã¡ããã覧ãã ããã
å®éã®ãµã¼ãã¼ç°å¢ä¸ã§éç¨ããéã®åé¡ç¹
ä¸ã§ç´¹ä»ããããã°è¨äºã§ã¯ãçæããã¯ã©ã¤ã¢ã³ãããã¼ã«ã«ã®Maven Repositoryã«ã¤ã³ã¹ãã¼ã«ããå©ç¨ãããããã¸ã§ã¯ãã§ä¾åé¢ä¿ã追å ãã¦å©ç¨ãã¾ããã
ãã¼ã«ã«ã®Maven Repositoryã¯ããã©ã«ãã§ã¯ã$USER/.m2/repository
ã«åå¨ãã¦ãã¾ãã
ãã¼ã«ã«ã§éçºãã¦ããéã¯è¯ãã®ã§ããããµã¼ãã¼ç°å¢ä¸ã«ãããã¤ããéã«ã¯ãã®Repositoryããã®ã¾ã¾ä½¿ããã¨ã¯ã§ãã¾ããã®ã§ãä½ãçãè¬ããªããã°ãªãã¾ããã
ããããã¯ãä¸è¨ã®åé¡ã解決ãã¦ããã¾ãã
ç¬èªã®Maven Repositoryãå©ç¨ãã
ãã®åé¡ã®è§£æ±ºæ¹æ³ã¨ãã¦ã¯ãç¬èªã®Maven Repositoryãå©ç¨ããããã«è¨å®ãããã¨ãæãããã¾ãã
ãããããMaven Repositoryã¯ä»¥ä¸ã®ãããªæ§æã«ãªã£ã¦ããã°ãã©ãã«é ç½®ãã¦ãã¦ãå©ç¨ãããã¨ãå¯è½ã§ãã
/{repository_root}/{group ID}/{artifact ID}/{version}/
group ID
, artifact ID
, version
ã¯ãpom.xml
ãå©ç¨ãã¦è¨å®ãä¾åé¢ä¿ãè¨è¿°ãã¦ãã人ãªã馴æã¿æ·±ãã§ãããã
ä¾ãã°ãOpenAPIãSpring Bootã§å©ç¨ããããã®ãSpringdocã¨ããã©ã¤ãã©ãªã追å ããéã«ã¯ãpom.xml
ã«ä»¥ä¸ã®ããã«è¨è¿°ãã¾ãã
<dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <version>2.3.0</version> </dependency>
ã¤ã¾ãããã®è¨å®ã¯Maven Repositoryã®
/{repository_root}/org/springdoc/springdoc-openapi-starter-webmvc-ui/2.3.0
é ä¸ã«ããã©ã¤ãã©ãªãä¾åé¢ä¿ã¨ãã¦è¿½å ããã¨ãããã¨ã表ãã¦ããã®ã§ãã
ããã¦ããã®é ä¸ã«ä¸»ã«ä»¥ä¸ã®4ã¤ã®ãã¡ã¤ã«ãé ç½®ããã¦ãã¾ãã
- {artifact ID}-{version}.pom
- {artifact ID}-{version}.jar
- {artifact ID}-{version}-sources.jar
- {artifact ID}-{version}-javadoc.jar
éã«è¨ãã°ããã®æ§æã好ããªå ´æã«åç¾ãã¦å©ç¨ããã°è¯ãã®ã§ãã
ãã®ã好ããªå ´æãã¯ãå¥ã®ãµã¼ãã¼ä¸ãAWSã®S3ã®ãããªãªãã¸ã§ã¯ãã¹ãã¬ã¼ã¸ã§ãå¯è½ã§ãã
build.gradle
ããåç
§ããéã«ã¯ã以ä¸ã®ããã«è¨è¿°ãã¦ããã°ãã©ã¤ãã©ãªãæ¢ãã¨ãã«ãã®ä¸ãè¦ã¦ãããããã«ãªãã¾ãã
repositories { mavenCentral() maven { url {å©ç¨ãããMaven Repositoryã®URL} } }
ãªããã©ã¤ãã©ãªãæ¢ãéã«ã¯ãrepositories
ã§æå®ããé çªã§æ¢ãã«è¡ãããã§ãã
ãããã£ã¦ãmavenCentral()
ããåå¾ããã©ã¤ãã©ãªãå¤ãå ´åã«ã¯ããã¡ããä¸ã«è¨è¿°ãããã¨ã§ããã«ãæéãç縮ãããã¨ãå¯è½ã§ãã
ç¬èªã®ã©ã¤ãã©ãªãå¤ãå©ç¨ããå¿
è¦ãããå ´åã«ã¯ãå¥ã®ãµã¼ãã¼ä¸ãS3ã§Maven Repositoryã管çããã¡ãªãããããã¾ãã
ããããå½åä»åä½æããAPIã¯ã©ã¤ã¢ã³ãããå©ç¨ããäºå®ããªããããªå ´åã«ã¯ããµã¼ãã¼ãS3ã«ä¿åãã¦ããæ¹æ³ã¯ä½æã管çã®æéãããã£ã¦ãã¾ãã¾ãã
ãã®ãããªå ´åã«ã¯ãMaven Repositoryãããã¸ã§ã¯ãå
ã«å«ãã¦ãã¾ã¨ãã¦ãããã¤ãã¦ãã¾ãæ¹æ³ãé¸æè¢ã«å
¥ãã¾ãã
JARãã¡ã¤ã«ã¯å§ç¸®ããã¦ããããããã¡ã¤ã«ãµã¤ãºçã«ã¯åé¡ã«ã¯ãªããªãã§ãããã
ä»åã¯ããã¡ãã®æ¹æ³ããç´¹ä»ãã¾ãã
ã¨ãã£ã¦ãããããã¨ã¯ç°¡åã§ãã
åºç¤ç·¨ã§ã¯ã以ä¸ã®ã³ãã³ãã§Local Repositoryã«APIã¯ã©ã¤ã¢ã³ããã¤ã³ã¹ãã¼ã«ãã¦ãã¾ããã
mvn clean install
å
ã»ã©è¿°ã¹ãããã«ããã®ã¾ã¾ã§ã¯ããã©ã«ãã®ãã¼ã«ã«ãªãã¸ããªã§ãã$USER/.m2/repository
é
ä¸ã«ã¤ã³ã¹ãã¼ã«ããã¦ãã¾ãã¾ãã
ããã§ã-Dmaven.repo.local
ãªãã·ã§ã³ãä»ä¸ãããã¨ã§ãä¸æçã«Local Repositoryã®å ´æãå¤æ´ãããã¨ãã§ãã¾ãã
mvn clean install -Dmaven.repo.local=./{path_to_local_repository}
{path_to_local_repository}
ã®é¨åã«ãèªèº«ãè¨å®ãããlocal_repositoryã®å ´æãæå®ãã¦ããããã¨ã§ããã®å ´æã«APIã¯ã©ã¤ã¢ã³ããã¤ã³ã¹ãã¼ã«ããã¾ãã
ãã ãããã®ã¾ã¾ã§ã¯çæããAPIã¯ã©ã¤ã¢ã³ã以å¤ã«ãä¸è¦ãªã©ã¤ãã©ãªãã¤ã³ã¹ãã¼ã«ããã¦ãã¾ãã¾ãã
ï¼ãã®APIã¯ã©ã¤ã¢ã³ãã®pom.xml
ã§è¨å®ããã¦ããã©ã¤ãã©ãªãï¼ï¼
ãããã¯ãå®éã«APIã¯ã©ã¤ã¢ã³ããå©ç¨ããä¸ã§ã¯ä¸è¦ãªã®ã§ãAPIã¯ã©ã¤ã¢ã³ããå«ãã ãã£ã¬ã¯ããªã ããã³ãã¼ãã¦é©å½ãªãã£ã¬ã¯ããªã«ãã¼ã¹ããã¦ããã¾ãã
ä¾ãã°ã以ä¸ã®ãããªãã£ã¬ã¯ããªæ§æã¨ãªã£ã¦ããããclientgen
ãã£ã¬ã¯ããªã«APIã¯ã©ã¤ã¢ã³ããèªåçæããã¦ããã¨ãã¾ãã
ãã®å ´åã«ã¯ã以ä¸ã®ãããªã³ãã³ããå®è¡ãããã¨ã§ãlocal_repository
ã«ããã¸ã§ã¯ãã§å©ç¨ããAPIã¯ã©ã¤ã¢ã³ãã®ã¿ãå«ãã Maven Repositoryãæ§æãããã¨ãã§ãã¾ãã
ããããããlocal_repository
é
ä¸ã«com/example
ã¨ãã空ãã£ã¬ã¯ããªãä½æãã¦ããã¦ãã ããã
ï¼ç¾å¨ãããã¸ã§ã¯ãã«ã¼ãã«ããã¨ãã¾ããï¼
cd clientgen mvn clean install -Dmaven.repo.local=./local_repository_temp cp -rf ./local_repository_temp/com/example/openapi-java-client ./../local_repository/com/example
次ã«ãã©ã¤ãã©ãªãåå¾ããå ã®Maven Repositoryãè¨å®ãã¾ãã
repositories { mavenCentral() maven { url "$rootDir/local_repository" } }
ä¾åé¢ä¿ã追å ãã¾ãã
dependencies {
ãã ç¥ ãã
implementation "com.example:openapi-java-client:0.0.1-SNAPSHOT"
}
ããã§ãããã¸ã§ã¯ãå
ã§APIã¯ã©ã¤ã¢ã³ããå©ç¨ã§ããããã«ãªãã¾ããã
èªåçæããAPIã¯ã©ã¤ã¢ã³ããã®ãã®ï¼clientgen
é
ä¸ï¼ãlocal_repository_temp
ãã£ã¬ã¯ããªã¯.gitignore
ã«è¨è¿°ããï¼Gitãå©ç¨ãã¦ããå ´åï¼ããåé¤ãã¦ããã¨è¯ãã§ãããã
ãããã«
ä»åã¯ãèªåçæããAPIã¯ã©ã¤ã¢ã³ããããã¸ã§ã¯ãå ã®èªä½ã®Maven Repositoryã«ä¿åãã¦ãµã¼ãã¼ç°å¢ä¸ã§ãå©ç¨ã§ããããã«ããããã®è¨å®æ¹æ³ããç´¹ä»ãã¾ããã
ã§ã¯ãã¾ã次åã