Showing preview only (462K chars total). Download the full file or copy to clipboard to get everything.
Repository: springdoc/springdoc-openapi-demos
Branch: master
Commit: c95efaf3dc48
Files: 238
Total size: 382.0 KB
Directory structure:
gitextract_h9gh0xwv/
├── .gitattributes
├── .gitignore
├── Jenkinsfile
├── LICENSE
├── README.md
├── SUPPORT.md
├── demo-book-service/
│ ├── .gitignore
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── springdoc/
│ │ │ └── demo/
│ │ │ └── services/
│ │ │ └── book/
│ │ │ ├── SpringdocApplication.java
│ │ │ ├── controller/
│ │ │ │ └── BookController.java
│ │ │ ├── exception/
│ │ │ │ ├── BookNotFoundException.java
│ │ │ │ └── GlobalControllerExceptionHandler.java
│ │ │ ├── model/
│ │ │ │ └── Book.java
│ │ │ └── repository/
│ │ │ └── BookRepository.java
│ │ └── resources/
│ │ ├── application.yml
│ │ └── logback.xml
│ └── test/
│ └── java/
│ └── org/
│ └── springdoc/
│ └── demo/
│ └── services/
│ └── book/
│ └── SwaggerUnitTest.java
├── demo-microservices/
│ ├── .gitignore
│ ├── README.md
│ ├── config-service/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── springdoc/
│ │ │ └── demo/
│ │ │ └── services/
│ │ │ └── config/
│ │ │ └── ConfigApplication.java
│ │ └── resources/
│ │ ├── application.yml
│ │ └── config/
│ │ ├── department-service.yml
│ │ ├── discovery-service.yml
│ │ ├── employee-service.yml
│ │ ├── gateway-service.yml
│ │ └── organization-service.yml
│ ├── department-service/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── springdoc/
│ │ │ └── demo/
│ │ │ └── services/
│ │ │ └── department/
│ │ │ ├── DepartmentApplication.java
│ │ │ ├── client/
│ │ │ │ └── EmployeeClient.java
│ │ │ ├── controller/
│ │ │ │ └── DepartmentController.java
│ │ │ ├── model/
│ │ │ │ ├── Department.java
│ │ │ │ └── Employee.java
│ │ │ └── repository/
│ │ │ └── DepartmentRepository.java
│ │ └── resources/
│ │ └── application.yml
│ ├── discovery-service/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── springdoc/
│ │ │ └── demo/
│ │ │ └── services/
│ │ │ └── discovery/
│ │ │ └── DiscoveryApplication.java
│ │ └── resources/
│ │ └── application.yml
│ ├── employee-service/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── springdoc/
│ │ │ └── demo/
│ │ │ └── services/
│ │ │ └── employee/
│ │ │ ├── EmployeeApplication.java
│ │ │ ├── controller/
│ │ │ │ └── EmployeeController.java
│ │ │ ├── model/
│ │ │ │ └── Employee.java
│ │ │ └── repository/
│ │ │ └── EmployeeRepository.java
│ │ └── resources/
│ │ └── application.yml
│ ├── gateway-service/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── springdoc/
│ │ │ └── demo/
│ │ │ └── services/
│ │ │ └── gateway/
│ │ │ ├── ContextPathRewritePathGatewayFilterFactory.java
│ │ │ └── GatewayApplication.java
│ │ └── resources/
│ │ └── application.yml
│ ├── organization-service/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── springdoc/
│ │ │ └── demo/
│ │ │ └── services/
│ │ │ └── organization/
│ │ │ ├── OrganizationApplication.java
│ │ │ ├── client/
│ │ │ │ ├── DepartmentClient.java
│ │ │ │ └── EmployeeClient.java
│ │ │ ├── controller/
│ │ │ │ └── OrganizationController.java
│ │ │ ├── model/
│ │ │ │ ├── Department.java
│ │ │ │ ├── Employee.java
│ │ │ │ └── Organization.java
│ │ │ └── repository/
│ │ │ └── OrganizationRepository.java
│ │ └── resources/
│ │ └── application.yml
│ └── pom.xml
├── demo-oauth2/
│ ├── .gitignore
│ ├── README.md
│ ├── oauth-authorization-server/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── springdoc/
│ │ │ └── demo/
│ │ │ └── auth/
│ │ │ ├── AuthorizationServerApp.java
│ │ │ ├── DefaultSecurityConfig.java
│ │ │ ├── Jwks.java
│ │ │ ├── KeyGeneratorUtils.java
│ │ │ └── SecurityConfig.java
│ │ └── resources/
│ │ └── application.yml
│ ├── oauth-resource-server-webflux/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── springdoc/
│ │ │ └── demo/
│ │ │ └── resource/
│ │ │ ├── ResourceServerApp.java
│ │ │ ├── config/
│ │ │ │ ├── OpenApiConfig.java
│ │ │ │ └── SecurityConfig.java
│ │ │ ├── model/
│ │ │ │ └── Foo.java
│ │ │ ├── repository/
│ │ │ │ └── IFooRepository.java
│ │ │ ├── service/
│ │ │ │ ├── IFooService.java
│ │ │ │ └── impl/
│ │ │ │ └── FooServiceImpl.java
│ │ │ └── web/
│ │ │ ├── controller/
│ │ │ │ ├── FooController.java
│ │ │ │ └── UserInfoController.java
│ │ │ └── dto/
│ │ │ └── FooDTO.java
│ │ └── resources/
│ │ ├── application.yml
│ │ └── data.sql
│ ├── oauth-resource-server-webmvc/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── springdoc/
│ │ │ └── demo/
│ │ │ └── resource/
│ │ │ ├── ResourceServerApp.java
│ │ │ ├── config/
│ │ │ │ ├── OpenApiConfig.java
│ │ │ │ └── SecurityConfig.java
│ │ │ ├── model/
│ │ │ │ └── Foo.java
│ │ │ ├── repository/
│ │ │ │ └── IFooRepository.java
│ │ │ ├── service/
│ │ │ │ ├── IFooService.java
│ │ │ │ └── impl/
│ │ │ │ └── FooServiceImpl.java
│ │ │ └── web/
│ │ │ ├── controller/
│ │ │ │ ├── FooController.java
│ │ │ │ └── UserInfoController.java
│ │ │ └── dto/
│ │ │ └── FooDTO.java
│ │ └── resources/
│ │ ├── application.yml
│ │ └── data.sql
│ └── pom.xml
├── demo-person-service/
│ ├── .gitattributes
│ ├── .gitignore
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ └── main/
│ ├── java/
│ │ └── org/
│ │ └── springdoc/
│ │ └── demo/
│ │ └── services/
│ │ └── person/
│ │ ├── SampleApplication.java
│ │ ├── config/
│ │ │ └── SampleConfig.java
│ │ ├── controller/
│ │ │ └── PersonController.java
│ │ ├── exceptions/
│ │ │ ├── ErrorMessage.java
│ │ │ ├── GlobalControllerAdvice.java
│ │ │ └── Problem.java
│ │ └── model/
│ │ └── Person.java
│ └── resources/
│ └── application.properties
├── demo-spring-boot-3-webflux/
│ ├── .gitignore
│ ├── .java-version
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ └── main/
│ ├── java/
│ │ └── org/
│ │ └── springdoc/
│ │ └── demo/
│ │ └── app3/
│ │ ├── WebfluxDemoApplication.java
│ │ ├── controller/
│ │ │ ├── ExceptionTranslator.java
│ │ │ ├── TweetController.java
│ │ │ └── TweetMapper.java
│ │ ├── dto/
│ │ │ └── TweetDTO.java
│ │ ├── exception/
│ │ │ └── TweetNotFoundException.java
│ │ ├── model/
│ │ │ └── Tweet.java
│ │ ├── payload/
│ │ │ └── ErrorResponse.java
│ │ └── repository/
│ │ └── TweetRepository.java
│ └── resources/
│ ├── META-INF/
│ │ └── native-image/
│ │ └── reflect-config.json
│ └── application.yml
├── demo-spring-boot-3-webflux-functional/
│ ├── .gitignore
│ ├── pom.xml
│ └── src/
│ └── main/
│ ├── java/
│ │ └── org/
│ │ └── springdoc/
│ │ └── demo/
│ │ └── app4/
│ │ ├── AppNativeConfiguration.java
│ │ ├── WebfluxFunctionalDemoApplication.java
│ │ ├── coffee/
│ │ │ ├── Coffee.java
│ │ │ ├── CoffeeOrder.java
│ │ │ ├── CoffeeRepository.java
│ │ │ ├── CoffeeService.java
│ │ │ └── RouteConfig.java
│ │ ├── employee/
│ │ │ ├── Employee.java
│ │ │ ├── EmployeeFunctionalConfig.java
│ │ │ └── EmployeeRepository.java
│ │ └── user/
│ │ ├── RoutingConfiguration.java
│ │ ├── User.java
│ │ ├── UserHandler.java
│ │ ├── UserRepository.java
│ │ └── UserRepositoryImpl.java
│ └── resources/
│ ├── application.yml
│ ├── logback-spring.xml
│ └── schema.sql
├── demo-spring-boot-3-webmvc/
│ ├── .gitignore
│ ├── .java-version
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ └── main/
│ ├── java/
│ │ └── org/
│ │ └── springdoc/
│ │ └── demo/
│ │ └── app2/
│ │ ├── Application.java
│ │ ├── api/
│ │ │ ├── ApiUtil.java
│ │ │ ├── ExceptionTranslator.java
│ │ │ ├── PetApi.java
│ │ │ ├── PetApiController.java
│ │ │ ├── PetApiDelegate.java
│ │ │ ├── PetApiDelegateImpl.java
│ │ │ ├── StoreApi.java
│ │ │ ├── StoreApiController.java
│ │ │ ├── StoreApiDelegate.java
│ │ │ ├── StoreApiDelegateImpl.java
│ │ │ ├── UserApi.java
│ │ │ ├── UserApiController.java
│ │ │ ├── UserApiDelegate.java
│ │ │ └── UserApiDelegateImpl.java
│ │ ├── model/
│ │ │ ├── Body.java
│ │ │ ├── Body1.java
│ │ │ ├── Category.java
│ │ │ ├── ModelApiResponse.java
│ │ │ ├── Order.java
│ │ │ ├── Pet.java
│ │ │ ├── Tag.java
│ │ │ └── User.java
│ │ └── repository/
│ │ ├── HashMapRepository.java
│ │ ├── OrderRepository.java
│ │ ├── PetRepository.java
│ │ └── UserRepository.java
│ └── resources/
│ ├── application.yml
│ └── petstore.yml
├── demo-spring-boot-webflux-scalar/
│ ├── pom.xml
│ ├── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── springdoc/
│ │ │ └── demo/
│ │ │ └── app3/
│ │ │ ├── WebfluxDemoApplication.java
│ │ │ ├── controller/
│ │ │ │ ├── ExceptionTranslator.java
│ │ │ │ ├── TweetController.java
│ │ │ │ └── TweetMapper.java
│ │ │ ├── dto/
│ │ │ │ └── TweetDTO.java
│ │ │ ├── exception/
│ │ │ │ └── TweetNotFoundException.java
│ │ │ ├── model/
│ │ │ │ └── Tweet.java
│ │ │ ├── payload/
│ │ │ │ └── ErrorResponse.java
│ │ │ └── repository/
│ │ │ └── TweetRepository.java
│ │ └── resources/
│ │ └── application.yml
│ └── target/
│ └── maven-status/
│ └── maven-compiler-plugin/
│ └── compile/
│ └── default-compile/
│ ├── createdFiles.lst
│ └── inputFiles.lst
├── demo-spring-boot-webmvc-scalar/
│ ├── pom.xml
│ └── src/
│ └── main/
│ ├── java/
│ │ └── org/
│ │ └── springdoc/
│ │ └── demo/
│ │ └── services/
│ │ └── book/
│ │ ├── SpringdocApplication.java
│ │ ├── controller/
│ │ │ └── BookController.java
│ │ ├── exception/
│ │ │ ├── BookNotFoundException.java
│ │ │ └── GlobalControllerExceptionHandler.java
│ │ ├── model/
│ │ │ └── Book.java
│ │ └── repository/
│ │ └── BookRepository.java
│ └── resources/
│ ├── application.yml
│ └── logback.xml
├── demo-spring-cloud-function/
│ ├── .gitignore
│ ├── pom.xml
│ ├── spring-cloud-function-webflux/
│ │ ├── .gitignore
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── org/
│ │ │ └── springdoc/
│ │ │ └── demo/
│ │ │ └── services/
│ │ │ └── functions/
│ │ │ ├── PersonDTO.java
│ │ │ └── SampleApplication.java
│ │ └── resources/
│ │ └── application.yml
│ └── spring-cloud-function-webmvc/
│ ├── .gitignore
│ ├── pom.xml
│ └── src/
│ └── main/
│ ├── java/
│ │ └── org/
│ │ └── springdoc/
│ │ └── demo/
│ │ └── services/
│ │ └── functions/
│ │ ├── PersonDTO.java
│ │ └── SampleApplication.java
│ └── resources/
│ └── application.yml
├── demo-spring-data-rest/
│ ├── .gitignore
│ ├── pom.xml
│ └── src/
│ └── main/
│ ├── java/
│ │ └── org/
│ │ └── springdoc/
│ │ └── demo/
│ │ └── data/
│ │ └── rest/
│ │ ├── Account.java
│ │ ├── AccountRepository.java
│ │ ├── Customer.java
│ │ ├── CustomerRepository.java
│ │ └── SpringdocApplication.java
│ └── resources/
│ └── application.properties
├── demo-spring-hateoas/
│ ├── .gitignore
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ └── main/
│ ├── java/
│ │ └── org/
│ │ └── springdoc/
│ │ └── demo/
│ │ └── services/
│ │ └── hateoas/
│ │ ├── DatabaseLoader.java
│ │ ├── Employee.java
│ │ ├── EmployeeController.java
│ │ ├── EmployeeRepository.java
│ │ └── SpringdocApplication.java
│ └── resources/
│ └── application.properties
├── pom.xml
└── settings.xml
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf
================================================
FILE: .gitignore
================================================
######################
# Project Specific
######################
/target/www/**
/src/test/javascript/coverage/
######################
# Node
######################
/node/
node_tmp/
node_modules/
npm-debug.log.*
/.awcache/*
/.cache-loader/*
######################
# SASS
######################
.sass-cache/
######################
# Eclipse
######################
*.pydevproject
.project
.metadata
tmp/
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
.factorypath
/src/main/resources/rebel.xml
# External tool builders
.externalToolBuilders/**
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
######################
# Intellij
######################
.idea/
*.iml
*.iws
*.ipr
*.ids
*.orig
classes/
out/
######################
# Visual Studio Code
######################
.vscode/
######################
# Maven
######################
/log/
/target/
######################
# Gradle
######################
.gradle/
/build/
######################
# Package Files
######################
*.jar
*.war
*.ear
*.db
######################
# Windows
######################
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
######################
# Mac OSX
######################
.DS_Store
.svn
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
######################
# Directories
######################
/bin/
/deploy/
######################
# Logs
######################
*.log*
######################
# Others
######################
*.class
*.*~
*~
.merge_file*
######################
# Gradle Wrapper
######################
!gradle/wrapper/gradle-wrapper.jar
######################
# Maven Wrapper
######################
!.mvn/wrapper/maven-wrapper.jar
######################
# ESLint
######################
.eslintcache
# Ignore Gradle project-specific cache directory
.gradle
# Ignore Gradle build output directory
build
================================================
FILE: Jenkinsfile
================================================
#!/usr/bin/env groovy
node {
stage('checkout') {
deleteDir()
checkout scm
}
stage('Clean') {
withMaven(jdk: 'java-17', maven: 'maven-3.8.4'){
sh "mvn clean -T100"
}
}
stage('Package') {
withMaven(jdk: 'java-17', maven: 'maven-3.8.4'){
sh "mvn -Pjib package jib:build -T100"
}
}
stage("Deploy") {
build 'springdoc-openapi-demos-v2-deploy'
deleteDir()
}
}
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
[](https://ci-cd.springdoc.org:8443/view/springdoc-openapi-demos/job/springdoc-openapi-demos/job/master/)
# Spring-boot with OpenAPI Demo applications.
## [Demo Spring Boot 3 Web MVC with OpenAPI 3](https://demos.springdoc.org/demo-spring-boot-3-webmvc).
## [Demo Spring Boot 3 WebFlux with OpenAPI 3](https://demos.springdoc.org/demo-spring-boot-3-webflux/swagger-ui.html).
## [Demo Spring Boot 3 Web MVC with OpenAPI 3 and Scalar](https://demos.springdoc.org/demo-spring-boot-webmvc-scalar/scalar).
## [Demo Spring Boot 3 WebFlux with OpenAPI 3 and Scalar](https://demos.springdoc.org/demo-spring-boot-webflux-scalar/scalar).
## [Demo Spring Boot 3 WebFlux with Functional endpoints OpenAPI 3](https://demos.springdoc.org/demo-spring-boot-3-webflux-functional/swagger-ui.html).
## [Demo Spring Boot 3 and Spring Cloud Function Web MVC](https://demos.springdoc.org/spring-cloud-function-webmvc).
## [Demo Spring Boot 3 and Spring Cloud Function WebFlux](https://demos.springdoc.org/spring-cloud-function-webflux/swagger-ui.html).
## [Demo Spring Boot 3 and Spring Cloud Gateway](https://demos.springdoc.org/demo-microservices/swagger-ui.html).

# **Thank you for the support**
* Thanks a lot [JetBrains](https://www.jetbrains.com/?from=springdoc-openapi) for
supporting springdoc-openapi project.

================================================
FILE: SUPPORT.md
================================================
## Where to get help
If you think you've found a bug in The Architect Theme,
please [check the existing issues](https://github.com/pages-themes/architect/issues), and
if no one has reported the
problem, [open a new issue](https://github.com/pages-themes/architect/issues/new).
If you have a general question about the theme, how to implement it, or how to customize
it for your site you have two options:
1. [Contact GitHub Support](https://github.com/contact?form%5Bsubject%5D=GitHub%20Pages%20theme%20pages-themes/architect)
, or
2. Ask your question of the Jekyll community
on [talk.jekyllrb.com](https://talk.jekyllrb.com/)
================================================
FILE: demo-book-service/.gitignore
================================================
######################
# Project Specific
######################
/target/www/**
/src/test/javascript/coverage/
######################
# Node
######################
/node/
node_tmp/
node_modules/
npm-debug.log.*
/.awcache/*
/.cache-loader/*
######################
# SASS
######################
.sass-cache/
######################
# Eclipse
######################
*.pydevproject
.project
.metadata
tmp/
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
.factorypath
/src/main/resources/rebel.xml
# External tool builders
.externalToolBuilders/**
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
######################
# Intellij
######################
.idea/
*.iml
*.iws
*.ipr
*.ids
*.orig
classes/
out/
######################
# Visual Studio Code
######################
.vscode/
######################
# Maven
######################
/log/
/target/
######################
# Gradle
######################
.gradle/
/build/
######################
# Package Files
######################
*.jar
*.war
*.ear
*.db
######################
# Windows
######################
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
######################
# Mac OSX
######################
.DS_Store
.svn
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
######################
# Directories
######################
/bin/
/deploy/
######################
# Logs
######################
*.log*
######################
# Others
######################
*.class
*.*~
*~
.merge_file*
######################
# Gradle Wrapper
######################
!gradle/wrapper/gradle-wrapper.jar
######################
# Maven Wrapper
######################
!.mvn/wrapper/maven-wrapper.jar
######################
# ESLint
######################
.eslintcache
================================================
FILE: demo-book-service/README.md
================================================
### Relevant Articles:
- [Documenting a Spring REST API Using OpenAPI 3.0](https://www.baeldung.com/spring-rest-openapi-documentation)
================================================
FILE: demo-book-service/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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.springdoc</groupId>
<artifactId>springdoc-openapi-demos</artifactId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<artifactId>demo-book-service</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
</dependency>
<!-- Runtime library -->
<dependency>
<groupId>com.github.therapi</groupId>
<artifactId>therapi-runtime-javadoc</artifactId>
<version>0.15.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>com.github.therapi</groupId>
<artifactId>therapi-runtime-javadoc-scribe</artifactId>
<version>0.15.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: demo-book-service/src/main/java/org/springdoc/demo/services/book/SpringdocApplication.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.services.book;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringdocApplication {
public static void main(String[] args) {
SpringApplication.run(SpringdocApplication.class, args);
}
}
================================================
FILE: demo-book-service/src/main/java/org/springdoc/demo/services/book/controller/BookController.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.services.book.controller;
import java.util.Collection;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springdoc.demo.services.book.exception.BookNotFoundException;
import org.springdoc.demo.services.book.model.Book;
import org.springdoc.demo.services.book.repository.BookRepository;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
/**
* The type Book controller.
*/
@RestController
@RequestMapping("/api/book")
public class BookController {
/**
* The Repository.
*/
private final BookRepository repository;
/**
* Instantiates a new Book controller.
*
* @param repository the repository
*/
public BookController(BookRepository repository) {
this.repository = repository;
}
/**
* Find by id book.
*
* @param id the id
* @return the book
*/
@GetMapping("/{id}")
public Book findById(@PathVariable long id) {
return repository.findById(id)
.orElseThrow(() -> new BookNotFoundException());
}
/**
* Find books collection.
*
* @return the collection
*/
@GetMapping("/")
public Collection<Book> findBooks() {
return repository.getBooks();
}
/**
* Update book book.
*
* @param id the id
* @param book the book
* @return the book
*/
@PutMapping("/{id}")
@ResponseStatus(HttpStatus.OK)
public Book updateBook(@PathVariable("id") final String id, @RequestBody final Book book) {
return book;
}
/**
* Patch book book.
*
* @param id the id
* @param book the book
* @return the book
*/
@PatchMapping("/{id}")
@ResponseStatus(HttpStatus.OK)
public Book patchBook(@PathVariable("id") final String id, @RequestBody final Book book) {
return book;
}
/**
* Post book book.
*
* @param book the book
* @return the book
*/
@PostMapping("/")
@ResponseStatus(HttpStatus.CREATED)
public Book postBook(@NotNull @Valid @RequestBody final Book book) {
return book;
}
/**
* Head book book.
*
* @return the book
*/
@RequestMapping(method = RequestMethod.HEAD, value = "/")
@ResponseStatus(HttpStatus.OK)
public Book headBook() {
return new Book();
}
/**
* Delete book long.
*
* @param id the id
* @return the long
*/
@DeleteMapping("/{id}")
@ResponseStatus(HttpStatus.OK)
public long deleteBook(@PathVariable final long id) {
return id;
}
}
================================================
FILE: demo-book-service/src/main/java/org/springdoc/demo/services/book/exception/BookNotFoundException.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.services.book.exception;
@SuppressWarnings("serial")
public class BookNotFoundException extends RuntimeException {
public BookNotFoundException() {
}
}
================================================
FILE: demo-book-service/src/main/java/org/springdoc/demo/services/book/exception/GlobalControllerExceptionHandler.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.services.book.exception;
import java.time.Instant;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ProblemDetail;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
@RestControllerAdvice
public class GlobalControllerExceptionHandler extends ResponseEntityExceptionHandler {
@ExceptionHandler(ConversionFailedException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ProblemDetail handleConnversion(RuntimeException e) {
ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, e.getMessage());
problemDetail.setTitle("Bookmark is Not Found");
problemDetail.setProperty("errorCategory", "Generic Exception");
problemDetail.setProperty("timestamp", Instant.now());
return problemDetail;
}
@ExceptionHandler(BookNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public ProblemDetail handleBookNotFound(RuntimeException e) {
ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND, e.getMessage());
problemDetail.setTitle("Book Not Found");
problemDetail.setProperty("errorCategory", "Generic Exception");
problemDetail.setProperty("timestamp", Instant.now());
return problemDetail;
}
}
================================================
FILE: demo-book-service/src/main/java/org/springdoc/demo/services/book/model/Book.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.services.book.model;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
/**
* The type Book.
*/
public class Book {
/**
* The Id.
*/
private long id;
/**
* The Title.
*/
@NotBlank
@Size(min = 0, max = 20)
private String title;
/**
* The Author.
*/
@NotBlank
@Size(min = 0, max = 30)
private String author;
/**
* Gets id.
*
* @return the id
*/
public long getId() {
return id;
}
/**
* Sets id.
*
* @param id the id
*/
public void setId(long id) {
this.id = id;
}
/**
* Gets title.
*
* @return the title
*/
public String getTitle() {
return title;
}
/**
* Sets title.
*
* @param title the title
*/
public void setTitle(String title) {
this.title = title;
}
/**
* Gets author.
*
* @return the author
*/
public String getAuthor() {
return author;
}
/**
* Sets author.
*
* @param author the author
*/
public void setAuthor(String author) {
this.author = author;
}
}
================================================
FILE: demo-book-service/src/main/java/org/springdoc/demo/services/book/repository/BookRepository.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.services.book.repository;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.springdoc.demo.services.book.model.Book;
import org.springframework.stereotype.Repository;
@Repository
public class BookRepository {
private Map<Long, Book> books = new HashMap<>();
public Optional<Book> findById(long id) {
return Optional.ofNullable(books.get(id));
}
public void add(Book book) {
books.put(book.getId(), book);
}
public Collection<Book> getBooks() {
return books.values();
}
}
================================================
FILE: demo-book-service/src/main/resources/application.yml
================================================
server:
forward-headers-strategy: framework
springdoc:
version: '@springdoc.version@'
swagger-ui:
use-root-path: true
================================================
FILE: demo-book-service/src/main/resources/logback.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="org.springframework" level="INFO"/>
<logger name="org.springframework.transaction" level="WARN"/>
<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
================================================
FILE: demo-book-service/src/test/java/org/springdoc/demo/services/book/SwaggerUnitTest.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.services.book;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@AutoConfigureMockMvc
@SpringBootTest
public class SwaggerUnitTest {
@Autowired
protected MockMvc mockMvc;
@Test
public void shouldDisplaySwaggerUiPage() throws Exception {
MvcResult mvcResult = mockMvc.perform(get("/swagger-ui/index.html")).andExpect(status().isOk()).andReturn();
String contentAsString = mvcResult.getResponse().getContentAsString();
Assertions.assertTrue(contentAsString.contains("Swagger UI"));
}
}
================================================
FILE: demo-microservices/.gitignore
================================================
######################
# Project Specific
######################
/target/www/**
/src/test/javascript/coverage/
######################
# Node
######################
/node/
node_tmp/
node_modules/
npm-debug.log.*
/.awcache/*
/.cache-loader/*
######################
# SASS
######################
.sass-cache/
######################
# Eclipse
######################
*.pydevproject
.project
.metadata
tmp/
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
.factorypath
/src/main/resources/rebel.xml
# External tool builders
.externalToolBuilders/**
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
######################
# Intellij
######################
.idea/
*.iml
*.iws
*.ipr
*.ids
*.orig
classes/
out/
######################
# Visual Studio Code
######################
.vscode/
######################
# Maven
######################
/log/
/target/
######################
# Gradle
######################
.gradle/
/build/
######################
# Package Files
######################
*.jar
*.war
*.ear
*.db
######################
# Windows
######################
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
######################
# Mac OSX
######################
.DS_Store
.svn
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
######################
# Directories
######################
/bin/
/deploy/
######################
# Logs
######################
*.log*
######################
# Others
######################
*.class
*.*~
*~
.merge_file*
######################
# Gradle Wrapper
######################
!gradle/wrapper/gradle-wrapper.jar
######################
# Maven Wrapper
######################
!.mvn/wrapper/maven-wrapper.jar
######################
# ESLint
######################
.eslintcache
================================================
FILE: demo-microservices/README.md
================================================
## sample microservices architecture using spring-cloud-gateway/eureka/spring-cloud-config
### Relevant information:
* Swagger-ui : http://localhost:8060/swagger-ui.html
* Eureka: http://localhost:8761/
================================================
FILE: demo-microservices/config-service/.gitignore
================================================
/target/
/.classpath
/.project
/.settings/
================================================
FILE: demo-microservices/config-service/pom.xml
================================================
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>config-service</artifactId>
<parent>
<groupId>org.springdoc</groupId>
<artifactId>demo-microservices</artifactId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
</dependencies>
</project>
================================================
FILE: demo-microservices/config-service/src/main/java/org/springdoc/demo/services/config/ConfigApplication.java
================================================
package org.springdoc.demo.services.config;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication
@EnableConfigServer
public class ConfigApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(ConfigApplication.class).run(args);
}
}
================================================
FILE: demo-microservices/config-service/src/main/resources/application.yml
================================================
server:
port: 8088
spring:
profiles:
active: native
================================================
FILE: demo-microservices/config-service/src/main/resources/config/department-service.yml
================================================
server:
port: 8090
forward-headers-strategy: framework
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_SERVER:http://localhost:8761/eureka}
instance:
preferIpAddress: true
logging:
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss} ${LOG_LEVEL_PATTERN:-%5p} %m%n"
springdoc:
cache:
disabled: true
version: '@springdoc.version@'
================================================
FILE: demo-microservices/config-service/src/main/resources/config/discovery-service.yml
================================================
server:
port: 8761
forward-headers-strategy: framework
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_SERVER:http://localhost:8761/eureka}
registerWithEureka: false
fetchRegistry: false
================================================
FILE: demo-microservices/config-service/src/main/resources/config/employee-service.yml
================================================
server:
port: 8092
forward-headers-strategy: framework
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_SERVER:http://localhost:8761/eureka}
instance:
preferIpAddress: true
logging:
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss} ${LOG_LEVEL_PATTERN:-%5p} %m%n"
springdoc:
version: '@springdoc.version@'
cache:
disabled: true
================================================
FILE: demo-microservices/config-service/src/main/resources/config/gateway-service.yml
================================================
server:
port: 8060
forward-headers-strategy: framework
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_SERVER:http://localhost:8761/eureka}
instance:
preferIpAddress: true
logging:
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss} ${LOG_LEVEL_PATTERN:-%5p} %m%n"
level:
org.springframework.cloud.gateway: TRACE
org.springframework.http.server.reactive: TRACE
spring:
cloud:
gateway:
server:
webflux:
trusted-proxies: "192\\.168\\.0\\..*|10\\.88\\.0\\..*|127\\.0\\.0\\.1|144\\.24\\.171\\.248"
httpclient:
ssl:
useInsecureTrustManager: true
discovery:
locator:
enabled: true
routes:
- id: employee-service
uri: lb://employee-service
predicates:
- Path=/employee/**, /demo-microservices/employee/**
filters:
- ContextPathRewritePath=/demo-microservices/employee/(?<path>.*), /$\{path}
- RewritePath=/employee/(?<path>.*), /$\{path}
- id: department-service
uri: lb://department-service
predicates:
- Path=/department/**, /demo-microservices/department/**
filters:
- ContextPathRewritePath=/demo-microservices/department/(?<path>.*), /$\{path}
- RewritePath=/department/(?<path>.*), /$\{path}
- id: organization-service
uri: lb://organization-service
predicates:
- Path=/organization/**, /demo-microservices/organization/**
filters:
- ContextPathRewritePath=/demo-microservices/organization/(?<path>.*), /$\{path}
- RewritePath=/organization/(?<path>.*), /$\{path}
- id: openapi-proxy
uri: https://demos.springdoc.org
predicates:
- Path=/demo-microservices/v3/api-docs/**
filters:
- RewritePath=/demo-microservices/v3/api-docs/(?<path>.*), /demo-microservices/$\{path}/v3/api-docs
- id: openapi
uri: http://localhost:${server.port}
predicates:
- Path=/v3/api-docs/**
filters:
- RewritePath=/v3/api-docs/(?<path>.*), /$\{path}/v3/api-docs
springdoc:
cache:
disabled: true
version: '@springdoc.version@'
swagger-ui:
use-root-path: true
================================================
FILE: demo-microservices/config-service/src/main/resources/config/organization-service.yml
================================================
server:
port: 8091
forward-headers-strategy: framework
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_SERVER:http://localhost:8761/eureka}
instance:
preferIpAddress: true
logging:
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss} ${LOG_LEVEL_PATTERN:-%5p} %m%n"
springdoc:
version: '@springdoc.version@'
cache:
disabled: true
================================================
FILE: demo-microservices/department-service/.gitignore
================================================
/target/
/.classpath
/.project
/.settings/
================================================
FILE: demo-microservices/department-service/pom.xml
================================================
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springdoc</groupId>
<artifactId>demo-microservices</artifactId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<artifactId>department-service</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</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-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
</dependency>
</dependencies>
</project>
================================================
FILE: demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/DepartmentApplication.java
================================================
package org.springdoc.demo.services.department;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import org.springdoc.demo.services.department.model.Department;
import org.springdoc.demo.services.department.repository.DepartmentRepository;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@OpenAPIDefinition(info =
@Info(title = "Department API", version = "${springdoc.version}", description = "Documentation Department API v1.0")
)
public class DepartmentApplication {
public static void main(String[] args) {
SpringApplication.run(DepartmentApplication.class, args);
}
@Bean
DepartmentRepository repository() {
DepartmentRepository repository = new DepartmentRepository();
repository.add(new Department(1L, "Development"));
repository.add(new Department(1L, "Operations"));
repository.add(new Department(2L, "Development"));
repository.add(new Department(2L, "Operations"));
return repository;
}
}
================================================
FILE: demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/client/EmployeeClient.java
================================================
package org.springdoc.demo.services.department.client;
import java.util.List;
import org.springdoc.demo.services.department.model.Employee;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@FeignClient(name = "employee-service")
public interface EmployeeClient {
@GetMapping("/department/{departmentId}")
List<Employee> findByDepartment(@PathVariable("departmentId") Long departmentId);
}
================================================
FILE: demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/controller/DepartmentController.java
================================================
package org.springdoc.demo.services.department.controller;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.demo.services.department.client.EmployeeClient;
import org.springdoc.demo.services.department.model.Department;
import org.springdoc.demo.services.department.repository.DepartmentRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class DepartmentController {
private static final Logger LOGGER = LoggerFactory.getLogger(DepartmentController.class);
private DepartmentRepository repository;
private EmployeeClient employeeClient;
public DepartmentController(DepartmentRepository repository, EmployeeClient employeeClient) {
this.repository = repository;
this.employeeClient = employeeClient;
}
@PostMapping("/")
public Department add(@RequestBody Department department) {
LOGGER.info("Department add: {}", department);
return repository.add(department);
}
@GetMapping("/{id}")
public Department findById(@PathVariable("id") Long id) {
LOGGER.info("Department find: id={}", id);
return repository.findById(id);
}
@GetMapping("/")
public List<Department> findAll() {
LOGGER.info("Department find");
return repository.findAll();
}
@GetMapping("/organization/{organizationId}")
public List<Department> findByOrganization(@PathVariable("organizationId") Long organizationId) {
LOGGER.info("Department find: organizationId={}", organizationId);
return repository.findByOrganization(organizationId);
}
@GetMapping("/organization/{organizationId}/with-employees")
public List<Department> findByOrganizationWithEmployees(@PathVariable("organizationId") Long organizationId) {
LOGGER.info("Department find: organizationId={}", organizationId);
List<Department> departments = repository.findByOrganization(organizationId);
departments.forEach(d -> d.setEmployees(employeeClient.findByDepartment(d.getId())));
return departments;
}
}
================================================
FILE: demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/model/Department.java
================================================
package org.springdoc.demo.services.department.model;
import java.util.ArrayList;
import java.util.List;
public class Department {
private Long id;
private Long organizationId;
private String name;
private List<Employee> employees = new ArrayList<>();
public Department() {
}
public Department(Long organizationId, String name) {
super();
this.organizationId = organizationId;
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getOrganizationId() {
return organizationId;
}
public void setOrganizationId(Long organizationId) {
this.organizationId = organizationId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Employee> getEmployees() {
return employees;
}
public void setEmployees(List<Employee> employees) {
this.employees = employees;
}
@Override
public String toString() {
return "Department [id=" + id + ", organizationId=" + organizationId + ", name=" + name + "]";
}
}
================================================
FILE: demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/model/Employee.java
================================================
package org.springdoc.demo.services.department.model;
public class Employee {
private Long id;
private String name;
private int age;
private String position;
public Employee() {
}
public Employee(String name, int age, String position) {
this.name = name;
this.age = age;
this.position = position;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
@Override
public String toString() {
return "Employee [id=" + id + ", name=" + name + ", position=" + position + "]";
}
}
================================================
FILE: demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/repository/DepartmentRepository.java
================================================
package org.springdoc.demo.services.department.repository;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.springdoc.demo.services.department.model.Department;
public class DepartmentRepository {
private List<Department> departments = new ArrayList<>();
public Department add(Department department) {
department.setId((long) (departments.size() + 1));
departments.add(department);
return department;
}
public Department findById(Long id) {
Optional<Department> department = departments.stream().filter(a -> a.getId().equals(id)).findFirst();
if (department.isPresent())
return department.get();
else
return null;
}
public List<Department> findAll() {
return departments;
}
public List<Department> findByOrganization(Long organizationId) {
return departments.stream().filter(a -> a.getOrganizationId().equals(organizationId)).collect(Collectors.toList());
}
}
================================================
FILE: demo-microservices/department-service/src/main/resources/application.yml
================================================
spring:
application:
name: department-service
config:
import: "optional:configserver:${CONFIG_SERVER:http://localhost:8088}"
================================================
FILE: demo-microservices/discovery-service/.gitignore
================================================
/target/
/.settings/
/.classpath
/.project
================================================
FILE: demo-microservices/discovery-service/pom.xml
================================================
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springdoc</groupId>
<artifactId>demo-microservices</artifactId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<artifactId>discovery-service</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
</dependencies>
</project>
================================================
FILE: demo-microservices/discovery-service/src/main/java/org/springdoc/demo/services/discovery/DiscoveryApplication.java
================================================
package org.springdoc.demo.services.discovery;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class DiscoveryApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(DiscoveryApplication.class).run(args);
}
}
================================================
FILE: demo-microservices/discovery-service/src/main/resources/application.yml
================================================
spring:
application:
name: discovery-service
config:
import: "optional:configserver:${CONFIG_SERVER:http://localhost:8088}"
================================================
FILE: demo-microservices/employee-service/.gitignore
================================================
/target/
/.classpath
/.project
/.settings/
================================================
FILE: demo-microservices/employee-service/pom.xml
================================================
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springdoc</groupId>
<artifactId>demo-microservices</artifactId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<artifactId>employee-service</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</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-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
</dependency>
</dependencies>
</project>
================================================
FILE: demo-microservices/employee-service/src/main/java/org/springdoc/demo/services/employee/EmployeeApplication.java
================================================
package org.springdoc.demo.services.employee;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import org.springdoc.demo.services.employee.model.Employee;
import org.springdoc.demo.services.employee.repository.EmployeeRepository;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
@EnableDiscoveryClient
@OpenAPIDefinition(info =
@Info(title = "Employee API", version = "${springdoc.version}", description = "Documentation Employee API v1.0")
)
public class EmployeeApplication {
public static void main(String[] args) {
SpringApplication.run(EmployeeApplication.class, args);
}
@Bean
EmployeeRepository repository() {
EmployeeRepository repository = new EmployeeRepository();
repository.add(new Employee(1L, 1L, "John Smith", 34, "Analyst"));
repository.add(new Employee(1L, 1L, "Darren Hamilton", 37, "Manager"));
repository.add(new Employee(1L, 1L, "Tom Scott", 26, "Developer"));
repository.add(new Employee(1L, 2L, "Anna London", 39, "Analyst"));
repository.add(new Employee(1L, 2L, "Patrick Dempsey", 27, "Developer"));
repository.add(new Employee(2L, 3L, "Kevin Price", 38, "Developer"));
repository.add(new Employee(2L, 3L, "Ian Scott", 34, "Developer"));
repository.add(new Employee(2L, 3L, "Andrew Campton", 30, "Manager"));
repository.add(new Employee(2L, 4L, "Steve Franklin", 25, "Developer"));
repository.add(new Employee(2L, 4L, "Elisabeth Smith", 30, "Developer"));
return repository;
}
}
================================================
FILE: demo-microservices/employee-service/src/main/java/org/springdoc/demo/services/employee/controller/EmployeeController.java
================================================
package org.springdoc.demo.services.employee.controller;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.demo.services.employee.model.Employee;
import org.springdoc.demo.services.employee.repository.EmployeeRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class EmployeeController {
private static final Logger LOGGER = LoggerFactory.getLogger(EmployeeController.class);
private EmployeeRepository repository;
public EmployeeController(EmployeeRepository repository) {
this.repository = repository;
}
@PostMapping("/")
public Employee add(@RequestBody Employee employee) {
LOGGER.info("Employee add: {}", employee);
return repository.add(employee);
}
@GetMapping("/{id}")
public Employee findById(@PathVariable("id") Long id) {
LOGGER.info("Employee find: id={}", id);
return repository.findById(id);
}
@GetMapping("/")
public List<Employee> findAll() {
LOGGER.info("Employee find");
return repository.findAll();
}
@GetMapping("/department/{departmentId}")
public List<Employee> findByDepartment(@PathVariable("departmentId") Long departmentId) {
LOGGER.info("Employee find: departmentId={}", departmentId);
return repository.findByDepartment(departmentId);
}
@GetMapping("/organization/{organizationId}")
public List<Employee> findByOrganization(@PathVariable("organizationId") Long organizationId) {
LOGGER.info("Employee find: organizationId={}", organizationId);
return repository.findByOrganization(organizationId);
}
}
================================================
FILE: demo-microservices/employee-service/src/main/java/org/springdoc/demo/services/employee/model/Employee.java
================================================
package org.springdoc.demo.services.employee.model;
public class Employee {
private Long id;
private Long organizationId;
private Long departmentId;
private String name;
private int age;
private String position;
public Employee() {
}
public Employee(Long organizationId, Long departmentId, String name, int age, String position) {
this.organizationId = organizationId;
this.departmentId = departmentId;
this.name = name;
this.age = age;
this.position = position;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getOrganizationId() {
return organizationId;
}
public void setOrganizationId(Long organizationId) {
this.organizationId = organizationId;
}
public Long getDepartmentId() {
return departmentId;
}
public void setDepartmentId(Long departmentId) {
this.departmentId = departmentId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
@Override
public String toString() {
return "Employee [id=" + id + ", organizationId=" + organizationId + ", departmentId=" + departmentId
+ ", name=" + name + ", position=" + position + "]";
}
}
================================================
FILE: demo-microservices/employee-service/src/main/java/org/springdoc/demo/services/employee/repository/EmployeeRepository.java
================================================
package org.springdoc.demo.services.employee.repository;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.springdoc.demo.services.employee.model.Employee;
public class EmployeeRepository {
private List<Employee> employees = new ArrayList<>();
public Employee add(Employee employee) {
employee.setId((long) (employees.size() + 1));
employees.add(employee);
return employee;
}
public Employee findById(Long id) {
Optional<Employee> employee = employees.stream().filter(a -> a.getId().equals(id)).findFirst();
if (employee.isPresent())
return employee.get();
else
return null;
}
public List<Employee> findAll() {
return employees;
}
public List<Employee> findByDepartment(Long departmentId) {
return employees.stream().filter(a -> a.getDepartmentId().equals(departmentId)).collect(Collectors.toList());
}
public List<Employee> findByOrganization(Long organizationId) {
return employees.stream().filter(a -> a.getOrganizationId().equals(organizationId)).collect(Collectors.toList());
}
}
================================================
FILE: demo-microservices/employee-service/src/main/resources/application.yml
================================================
spring:
application:
name: employee-service
config:
import: "optional:configserver:${CONFIG_SERVER:http://localhost:8088}"
================================================
FILE: demo-microservices/gateway-service/.gitignore
================================================
/target/
/.classpath
/.project
/.settings/
================================================
FILE: demo-microservices/gateway-service/pom.xml
================================================
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springdoc</groupId>
<artifactId>demo-microservices</artifactId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<artifactId>gateway-service</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
</dependency>
</dependencies>
</project>
================================================
FILE: demo-microservices/gateway-service/src/main/java/org/springdoc/demo/services/gateway/ContextPathRewritePathGatewayFilterFactory.java
================================================
package org.springdoc.demo.services.gateway;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.RewritePathGatewayFilterFactory;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR;
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.addOriginalRequestUrl;
/**
* @author bnasslahsen
*/
@Component
public class ContextPathRewritePathGatewayFilterFactory extends RewritePathGatewayFilterFactory {
@Override
public GatewayFilter apply(Config config) {
String replacement = config.getReplacement().replace("$\\", "$");
return (exchange, chain) -> {
ServerHttpRequest req = exchange.getRequest();
addOriginalRequestUrl(exchange, req.getURI());
String path = req.getURI().getRawPath();
String newPath = path.replaceAll(config.getRegexp(), replacement);
ServerHttpRequest request = req.mutate().path(newPath).contextPath("/").build();
exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, request.getURI());
return chain.filter(exchange.mutate().request(request).build());
};
}
}
================================================
FILE: demo-microservices/gateway-service/src/main/java/org/springdoc/demo/services/gateway/GatewayApplication.java
================================================
package org.springdoc.demo.services.gateway;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springdoc.core.properties.AbstractSwaggerUiConfigProperties.SwaggerUrl;
import org.springdoc.core.properties.SwaggerUiConfigProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.cloud.gateway.route.RouteDefinitionLocator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
import static org.springdoc.core.utils.Constants.DEFAULT_API_DOCS_URL;
@SpringBootApplication
@EnableDiscoveryClient
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
}
@Bean
@Lazy(false)
public Set<SwaggerUrl> apis(RouteDefinitionLocator locator, SwaggerUiConfigProperties swaggerUiConfigProperties) {
Set<SwaggerUrl> urls = new HashSet<>();
List<RouteDefinition> definitions = locator.getRouteDefinitions().collectList().block();
definitions.stream().filter(routeDefinition -> routeDefinition.getId().matches(".*-service")).forEach(routeDefinition -> {
String name = routeDefinition.getId().replaceAll("-service", "");
SwaggerUrl swaggerUrl = new SwaggerUrl(name, DEFAULT_API_DOCS_URL+"/" + name, null);
urls.add(swaggerUrl);
});
swaggerUiConfigProperties.setUrls(urls);
return urls;
}
}
================================================
FILE: demo-microservices/gateway-service/src/main/resources/application.yml
================================================
spring:
application:
name: gateway-service
config:
import: "optional:configserver:${CONFIG_SERVER:http://localhost:8088}"
================================================
FILE: demo-microservices/organization-service/.gitignore
================================================
/target/
/.classpath
/.project
/.settings/
================================================
FILE: demo-microservices/organization-service/pom.xml
================================================
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springdoc</groupId>
<artifactId>demo-microservices</artifactId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<artifactId>organization-service</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</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-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
</dependency>
</dependencies>
</project>
================================================
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/OrganizationApplication.java
================================================
package org.springdoc.demo.services.organization;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import org.springdoc.demo.services.organization.model.Organization;
import org.springdoc.demo.services.organization.repository.OrganizationRepository;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@OpenAPIDefinition(info =
@Info(title = "Organization API", version = "${springdoc.version}", description = "Documentation Organization API v1.0")
)
public class OrganizationApplication {
public static void main(String[] args) {
SpringApplication.run(OrganizationApplication.class, args);
}
@Bean
OrganizationRepository repository() {
OrganizationRepository repository = new OrganizationRepository();
repository.add(new Organization("Microsoft", "Redmond, Washington, USA"));
repository.add(new Organization("Oracle", "Redwood City, California, USA"));
return repository;
}
}
================================================
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/client/DepartmentClient.java
================================================
package org.springdoc.demo.services.organization.client;
import java.util.List;
import org.springdoc.demo.services.organization.model.Department;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@FeignClient(name = "department-service")
public interface DepartmentClient {
@GetMapping("/organization/{organizationId}")
public List<Department> findByOrganization(@PathVariable("organizationId") Long organizationId);
@GetMapping("/organization/{organizationId}/with-employees")
public List<Department> findByOrganizationWithEmployees(@PathVariable("organizationId") Long organizationId);
}
================================================
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/client/EmployeeClient.java
================================================
package org.springdoc.demo.services.organization.client;
import java.util.List;
import org.springdoc.demo.services.organization.model.Employee;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@FeignClient(name = "employee-service")
public interface EmployeeClient {
@GetMapping("/organization/{organizationId}")
List<Employee> findByOrganization(@PathVariable("organizationId") Long organizationId);
}
================================================
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/controller/OrganizationController.java
================================================
package org.springdoc.demo.services.organization.controller;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.demo.services.organization.client.DepartmentClient;
import org.springdoc.demo.services.organization.client.EmployeeClient;
import org.springdoc.demo.services.organization.model.Organization;
import org.springdoc.demo.services.organization.repository.OrganizationRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class OrganizationController {
private static final Logger LOGGER = LoggerFactory.getLogger(OrganizationController.class);
private OrganizationRepository repository;
private DepartmentClient departmentClient;
private EmployeeClient employeeClient;
public OrganizationController(OrganizationRepository repository, DepartmentClient departmentClient, EmployeeClient employeeClient) {
this.repository = repository;
this.departmentClient = departmentClient;
this.employeeClient = employeeClient;
}
@PostMapping
public Organization add(@RequestBody Organization organization) {
LOGGER.info("Organization add: {}", organization);
return repository.add(organization);
}
@GetMapping
public List<Organization> findAll() {
LOGGER.info("Organization find");
return repository.findAll();
}
@GetMapping("/{id}")
public Organization findById(@PathVariable("id") Long id) {
LOGGER.info("Organization find: id={}", id);
return repository.findById(id);
}
@GetMapping("/{id}/with-departments")
public Organization findByIdWithDepartments(@PathVariable("id") Long id) {
LOGGER.info("Organization find: id={}", id);
Organization organization = repository.findById(id);
organization.setDepartments(departmentClient.findByOrganization(organization.getId()));
return organization;
}
@GetMapping("/{id}/with-departments-and-employees")
public Organization findByIdWithDepartmentsAndEmployees(@PathVariable("id") Long id) {
LOGGER.info("Organization find: id={}", id);
Organization organization = repository.findById(id);
organization.setDepartments(departmentClient.findByOrganizationWithEmployees(organization.getId()));
return organization;
}
@GetMapping("/{id}/with-employees")
public Organization findByIdWithEmployees(@PathVariable("id") Long id) {
LOGGER.info("Organization find: id={}", id);
Organization organization = repository.findById(id);
organization.setEmployees(employeeClient.findByOrganization(organization.getId()));
return organization;
}
}
================================================
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/model/Department.java
================================================
package org.springdoc.demo.services.organization.model;
import java.util.ArrayList;
import java.util.List;
public class Department {
private Long id;
private String name;
private List<Employee> employees = new ArrayList<>();
public Department() {
}
public Department(String name) {
super();
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Employee> getEmployees() {
return employees;
}
public void setEmployees(List<Employee> employees) {
this.employees = employees;
}
@Override
public String toString() {
return "Department [id=" + id + ", name=" + name + "]";
}
}
================================================
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/model/Employee.java
================================================
package org.springdoc.demo.services.organization.model;
public class Employee {
private Long id;
private String name;
private int age;
private String position;
public Employee() {
}
public Employee(String name, int age, String position) {
this.name = name;
this.age = age;
this.position = position;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
@Override
public String toString() {
return "Employee [id=" + id + ", name=" + name + ", position=" + position + "]";
}
}
================================================
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/model/Organization.java
================================================
package org.springdoc.demo.services.organization.model;
import java.util.ArrayList;
import java.util.List;
public class Organization {
private Long id;
private String name;
private String address;
private List<Department> departments = new ArrayList<>();
private List<Employee> employees = new ArrayList<>();
public Organization() {
}
public Organization(String name, String address) {
this.name = name;
this.address = address;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public List<Department> getDepartments() {
return departments;
}
public void setDepartments(List<Department> departments) {
this.departments = departments;
}
public List<Employee> getEmployees() {
return employees;
}
public void setEmployees(List<Employee> employees) {
this.employees = employees;
}
@Override
public String toString() {
return "Organization [id=" + id + ", name=" + name + ", address=" + address + "]";
}
}
================================================
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/repository/OrganizationRepository.java
================================================
package org.springdoc.demo.services.organization.repository;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.springdoc.demo.services.organization.model.Organization;
public class OrganizationRepository {
private List<Organization> organizations = new ArrayList<>();
public Organization add(Organization organization) {
organization.setId((long) (organizations.size() + 1));
organizations.add(organization);
return organization;
}
public Organization findById(Long id) {
Optional<Organization> organization = organizations.stream().filter(a -> a.getId().equals(id)).findFirst();
if (organization.isPresent())
return organization.get();
else
return null;
}
public List<Organization> findAll() {
return organizations;
}
}
================================================
FILE: demo-microservices/organization-service/src/main/resources/application.yml
================================================
spring:
application:
name: organization-service
config:
import: "optional:configserver:${CONFIG_SERVER:http://localhost:8088}"
================================================
FILE: demo-microservices/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>springdoc-openapi-demos</artifactId>
<groupId>org.springdoc</groupId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion>
<artifactId>demo-microservices</artifactId>
<modules>
<module>config-service</module>
<module>discovery-service</module>
<module>employee-service</module>
<module>department-service</module>
<module>organization-service</module>
<module>gateway-service</module>
</modules>
</project>
================================================
FILE: demo-oauth2/.gitignore
================================================
######################
# Project Specific
######################
/target/www/**
/src/test/javascript/coverage/
######################
# Node
######################
/node/
node_tmp/
node_modules/
npm-debug.log.*
/.awcache/*
/.cache-loader/*
######################
# SASS
######################
.sass-cache/
######################
# Eclipse
######################
*.pydevproject
.project
.metadata
tmp/
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
.factorypath
/src/main/resources/rebel.xml
# External tool builders
.externalToolBuilders/**
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
######################
# Intellij
######################
.idea/
*.iml
*.iws
*.ipr
*.ids
*.orig
classes/
out/
######################
# Visual Studio Code
######################
.vscode/
######################
# Maven
######################
/log/
/target/
######################
# Gradle
######################
.gradle/
/build/
######################
# Package Files
######################
*.jar
*.war
*.ear
*.db
######################
# Windows
######################
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
######################
# Mac OSX
######################
.DS_Store
.svn
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
######################
# Directories
######################
/bin/
/deploy/
######################
# Logs
######################
*.log*
######################
# Others
######################
*.class
*.*~
*~
.merge_file*
######################
# Gradle Wrapper
######################
!gradle/wrapper/gradle-wrapper.jar
######################
# Maven Wrapper
######################
!.mvn/wrapper/maven-wrapper.jar
######################
# ESLint
######################
.eslintcache
================================================
FILE: demo-oauth2/README.md
================================================
## Spring Security OAuth - New Stack
### Relevant information:
1. `oauth-authorization-server` is a Keycloak Authorization Server wrapped as a Spring
Boot application
2. There is one OAuth Client registered in the Authorization Server:
1. Client Id: newClient
2. Client secret: newClientSecret
3. Redirect Uris:
- http://127.0.0.1:8081/resource-server/swagger-ui/oauth2-redirect.html
- http://127.0.0.1:8082/resource-server/swagger-ui/oauth2-redirect.html
3. There is a test user registered in the Authorization Server:
- josh@test.com / 123
4. `oauth-resource-server-webmvc` is a Spring Boot WebMVC based RESTFul API, acting as a
backend Application
swagger-ui: http://127.0.0.1:8081/resource-server/swagger-ui.html
5. `oauth-resource-server-webflux` is a Spring Boot WebFlux based RESTFul API, acting as a
backend Application
swagger-ui: http://127.0.0.1:8082/resource-server/swagger-ui.html
================================================
FILE: demo-oauth2/oauth-authorization-server/.gitignore
================================================
######################
# Project Specific
######################
/target/www/**
/src/test/javascript/coverage/
######################
# Node
######################
/node/
node_tmp/
node_modules/
npm-debug.log.*
/.awcache/*
/.cache-loader/*
######################
# SASS
######################
.sass-cache/
######################
# Eclipse
######################
*.pydevproject
.project
.metadata
tmp/
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
.factorypath
/src/main/resources/rebel.xml
# External tool builders
.externalToolBuilders/**
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
######################
# Intellij
######################
.idea/
*.iml
*.iws
*.ipr
*.ids
*.orig
classes/
out/
######################
# Visual Studio Code
######################
.vscode/
######################
# Maven
######################
/log/
/target/
######################
# Gradle
######################
.gradle/
/build/
######################
# Package Files
######################
*.jar
*.war
*.ear
*.db
######################
# Windows
######################
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
######################
# Mac OSX
######################
.DS_Store
.svn
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
######################
# Directories
######################
/bin/
/deploy/
######################
# Logs
######################
*.log*
######################
# Others
######################
*.class
*.*~
*~
.merge_file*
######################
# Gradle Wrapper
######################
!gradle/wrapper/gradle-wrapper.jar
######################
# Maven Wrapper
######################
!.mvn/wrapper/maven-wrapper.jar
######################
# ESLint
######################
.eslintcache
================================================
FILE: demo-oauth2/oauth-authorization-server/pom.xml
================================================
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springdoc</groupId>
<artifactId>demo-oauth2</artifactId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<artifactId>oauth-authorization-server</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-authorization-server</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</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-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
</dependencies>
</project>
================================================
FILE: demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/AuthorizationServerApp.java
================================================
package org.springdoc.demo.auth;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class AuthorizationServerApp {
public static void main(String[] args) {
SpringApplication.run(AuthorizationServerApp.class, args);
}
}
================================================
FILE: demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/DefaultSecurityConfig.java
================================================
package org.springdoc.demo.auth;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;
import static org.springframework.security.config.Customizer.withDefaults;
@EnableWebSecurity
@Configuration(proxyBeanMethods = false)
public class DefaultSecurityConfig {
@Bean
SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(authz ->
authz.requestMatchers("/v3/api-docs/**", "/swagger-ui/**", "/swagger-ui.html").permitAll()
.anyRequest().authenticated()
)
.cors(withDefaults())
.formLogin(withDefaults());
return http.build();
}
@Bean
UserDetailsService users() {
UserDetails user = User.withDefaultPasswordEncoder()
.username("josh@test.com")
.password("123")
.roles("USER")
.build();
return new InMemoryUserDetailsManager(user);
}
}
================================================
FILE: demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/Jwks.java
================================================
package org.springdoc.demo.auth;
import java.security.KeyPair;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.util.UUID;
import com.nimbusds.jose.jwk.RSAKey;
public final class Jwks {
private Jwks() {
}
public static RSAKey generateRsa() {
KeyPair keyPair = KeyGeneratorUtils.generateRsaKey();
RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
return new RSAKey.Builder(publicKey)
.privateKey(privateKey)
.keyID(UUID.randomUUID().toString())
.build();
}
}
================================================
FILE: demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/KeyGeneratorUtils.java
================================================
package org.springdoc.demo.auth;
import java.math.BigInteger;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.spec.ECFieldFp;
import java.security.spec.ECParameterSpec;
import java.security.spec.ECPoint;
import java.security.spec.EllipticCurve;
final class KeyGeneratorUtils {
private KeyGeneratorUtils() {
}
static KeyPair generateRsaKey() {
KeyPair keyPair;
try {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(2048);
keyPair = keyPairGenerator.generateKeyPair();
}
catch (Exception ex) {
throw new IllegalStateException(ex);
}
return keyPair;
}
static KeyPair generateEcKey() {
EllipticCurve ellipticCurve = new EllipticCurve(
new ECFieldFp(
new BigInteger("115792089210356248762697446949407573530086143415290314195533631308867097853951")),
new BigInteger("115792089210356248762697446949407573530086143415290314195533631308867097853948"),
new BigInteger("41058363725152142129326129780047268409114441015993725554835256314039467401291"));
ECPoint ecPoint = new ECPoint(
new BigInteger("48439561293906451759052585252797914202762949526041747995844080717082404635286"),
new BigInteger("36134250956749795798585127919587881956611106672985015071877198253568414405109"));
ECParameterSpec ecParameterSpec = new ECParameterSpec(
ellipticCurve,
ecPoint,
new BigInteger("115792089210356248762697446949407573529996955224135760342422259061068512044369"),
1);
KeyPair keyPair;
try {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("EC");
keyPairGenerator.initialize(ecParameterSpec);
keyPair = keyPairGenerator.generateKeyPair();
}
catch (Exception ex) {
throw new IllegalStateException(ex);
}
return keyPair;
}
}
================================================
FILE: demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/SecurityConfig.java
================================================
package org.springdoc.demo.auth;
import java.util.List;
import java.util.UUID;
import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jose.jwk.RSAKey;
import com.nimbusds.jose.jwk.source.JWKSource;
import com.nimbusds.jose.proc.SecurityContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer;
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import org.springframework.security.oauth2.core.ClientAuthenticationMethod;
import org.springframework.security.oauth2.core.oidc.OidcScopes;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationConsentService;
import org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationService;
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationConsentService;
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
import org.springframework.security.oauth2.server.authorization.client.JdbcRegisteredClientRepository;
import org.springframework.security.oauth2.server.authorization.client.RegisteredClient;
import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository;
import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration;
import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer;
import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import static org.springframework.security.config.Customizer.withDefaults;
@Configuration(proxyBeanMethods = false)
public class SecurityConfig {
private static final List<String> ALLOWED_HEADERS = List.of("Access-Control-Allow-Origin", "x-requested-with");
private static final List<String> ALLOWED_METHODS = List.of("POST");
private static final List<String> ALLOWED_ALL = List.of("http://127.0.0.1:8081", "http://127.0.0.1:8082", "http://144.24.171.248:8095","http://144.24.171.248:8096", "https://demos.springdoc.org");
@Bean
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(ALLOWED_ALL);
configuration.setAllowedMethods(ALLOWED_METHODS);
configuration.setAllowedHeaders(ALLOWED_HEADERS);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception {
OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http);
http.getConfigurer(OAuth2AuthorizationServerConfigurer.class)
.oidc(Customizer.withDefaults());
http
.cors(withDefaults())
.exceptionHandling(exceptions ->
exceptions.authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/login"))
)
.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt);
return http.build();
}
@Bean
public RegisteredClientRepository registeredClientRepository(JdbcTemplate jdbcTemplate) {
RegisteredClient registeredClient = RegisteredClient.withId(UUID.randomUUID().toString())
.clientId("newClient")
.clientSecret("{noop}newClientSecret")
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_POST)
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
.authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)
.authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS)
.redirectUri("http://127.0.0.1:8081/resource-server/swagger-ui/oauth2-redirect.html")
.redirectUri("http://127.0.0.1:8082/resource-server/swagger-ui/oauth2-redirect.html")
.redirectUri("http://144.24.171.248:8095/resource-server/swagger-ui/oauth2-redirect.html")
.redirectUri("http://144.24.171.248:8096/resource-server/swagger-ui/oauth2-redirect.html")
.redirectUri("https://demos.springdoc.org/oauth-resource-server-webmvc/resource-server/swagger-ui/oauth2-redirect.html")
.redirectUri("https://demos.springdoc.org/oauth-resource-server-webflux/resource-server/swagger-ui/oauth2-redirect.html")
.scope(OidcScopes.OPENID)
.scope(OidcScopes.PROFILE)
.scope("springdoc.read")
.scope("springdoc.write")
.build();
// Save registered client in db as if in-memory
JdbcRegisteredClientRepository registeredClientRepository = new JdbcRegisteredClientRepository(jdbcTemplate);
registeredClientRepository.save(registeredClient);
return registeredClientRepository;
}
@Bean
public OAuth2AuthorizationService authorizationService(JdbcTemplate jdbcTemplate, RegisteredClientRepository registeredClientRepository) {
return new JdbcOAuth2AuthorizationService(jdbcTemplate, registeredClientRepository);
}
@Bean
public OAuth2AuthorizationConsentService authorizationConsentService(JdbcTemplate jdbcTemplate, RegisteredClientRepository registeredClientRepository) {
return new JdbcOAuth2AuthorizationConsentService(jdbcTemplate, registeredClientRepository);
}
@Bean
public JWKSource<SecurityContext> jwkSource() {
RSAKey rsaKey = Jwks.generateRsa();
JWKSet jwkSet = new JWKSet(rsaKey);
return (jwkSelector, securityContext) -> jwkSelector.select(jwkSet);
}
@Bean
public JwtDecoder jwtDecoder(JWKSource<SecurityContext> jwkSource) {
return OAuth2AuthorizationServerConfiguration.jwtDecoder(jwkSource);
}
@Bean
public AuthorizationServerSettings authorizationServerSettings() {
return AuthorizationServerSettings.builder().build();
}
@Bean
public EmbeddedDatabase embeddedDatabase() {
return new EmbeddedDatabaseBuilder()
.generateUniqueName(true)
.setType(EmbeddedDatabaseType.H2)
.setScriptEncoding("UTF-8")
.addScript("org/springframework/security/oauth2/server/authorization/oauth2-authorization-schema.sql")
.addScript("org/springframework/security/oauth2/server/authorization/oauth2-authorization-consent-schema.sql")
.addScript("org/springframework/security/oauth2/server/authorization/client/oauth2-registered-client-schema.sql")
.build();
}
}
================================================
FILE: demo-oauth2/oauth-authorization-server/src/main/resources/application.yml
================================================
spring:
datasource:
username: sa
url: jdbc:h2:./data/keycloak;DB_CLOSE_ON_EXIT=FALSE
hikari:
maximum-pool-size: 25
minimum-idle: 1
server:
forward-headers-strategy: native
port: 8083
logging:
level:
root: INFO
org.springframework.web: INFO
org.springframework.security: INFO
org.springframework.security.oauth2: INFO
org.springframework.boot.autoconfigure: INFO
springdoc:
show-oauth2-endpoints: true
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/.gitignore
================================================
######################
# Project Specific
######################
/target/www/**
/src/test/javascript/coverage/
######################
# Node
######################
/node/
node_tmp/
node_modules/
npm-debug.log.*
/.awcache/*
/.cache-loader/*
######################
# SASS
######################
.sass-cache/
######################
# Eclipse
######################
*.pydevproject
.project
.metadata
tmp/
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
.factorypath
/src/main/resources/rebel.xml
# External tool builders
.externalToolBuilders/**
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
######################
# Intellij
######################
.idea/
*.iml
*.iws
*.ipr
*.ids
*.orig
classes/
out/
######################
# Visual Studio Code
######################
.vscode/
######################
# Maven
######################
/log/
/target/
######################
# Gradle
######################
.gradle/
/build/
######################
# Package Files
######################
*.jar
*.war
*.ear
*.db
######################
# Windows
######################
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
######################
# Mac OSX
######################
.DS_Store
.svn
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
######################
# Directories
######################
/bin/
/deploy/
######################
# Logs
######################
*.log*
######################
# Others
######################
*.class
*.*~
*~
.merge_file*
######################
# Gradle Wrapper
######################
!gradle/wrapper/gradle-wrapper.jar
######################
# Maven Wrapper
######################
!.mvn/wrapper/maven-wrapper.jar
######################
# ESLint
######################
.eslintcache
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/pom.xml
================================================
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springdoc</groupId>
<artifactId>demo-oauth2</artifactId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<artifactId>oauth-resource-server-webflux</artifactId>
<dependencies>
<!-- web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<!-- security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
<!-- persistence -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<!-- OpenAPI 3 -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
</dependency>
</dependencies>
</project>
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/ResourceServerApp.java
================================================
package org.springdoc.demo.resource;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class ResourceServerApp {
public static void main(String[] args) throws Exception {
SpringApplication.run(ResourceServerApp.class, args);
}
@Bean
public OpenAPI customOpenAPI(@Value("${springdoc.version}") String appVersion) {
return new OpenAPI()
.components(new Components())
.info(new Info().title("Foo API").version(appVersion)
.license(new License().name("Apache 2.0").url("http://springdoc.org")));
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/config/OpenApiConfig.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.resource.config;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.security.OAuthFlow;
import io.swagger.v3.oas.annotations.security.OAuthFlows;
import io.swagger.v3.oas.annotations.security.OAuthScope;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
@OpenAPIDefinition(info = @Info(title = "My App",
description = "Some long and useful description", version = "v1"))
@SecurityScheme(name = "security_auth", type = SecuritySchemeType.OAUTH2,
flows = @OAuthFlows(authorizationCode = @OAuthFlow(
authorizationUrl = "${springdoc.oAuthFlow.authorizationUrl}"
, tokenUrl = "${springdoc.oAuthFlow.tokenUrl}", scopes = {
@OAuthScope(name = "springdoc.read", description = "read scope"),
@OAuthScope(name = "springdoc.write", description = "write scope") })))
public class OpenApiConfig {}
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/config/SecurityConfig.java
================================================
package org.springdoc.demo.resource.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;
@Configuration
public class SecurityConfig {
@Bean
public SecurityWebFilterChain configure(ServerHttpSecurity http) {
http
.authorizeExchange().pathMatchers("/v3/api-docs/**", "/swagger-ui/**", "/webjars/**", "/swagger-ui.html").permitAll()
.pathMatchers(HttpMethod.GET, "/user/info", "/api/foos/**")
.hasAuthority("SCOPE_springdoc.read")
.pathMatchers(HttpMethod.POST, "/api/foos")
.hasAuthority("SCOPE_springdoc.write")
.anyExchange().authenticated().and().oauth2ResourceServer().jwt();
return http.build();
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/model/Foo.java
================================================
package org.springdoc.demo.resource.model;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@Entity
public class Foo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
protected Foo() {
}
public Foo(String name) {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Foo other = (Foo) obj;
if (id == null) {
if (other.id != null)
return false;
}
else if (!id.equals(other.id))
return false;
if (name == null) {
if (other.name != null)
return false;
}
else if (!name.equals(other.name))
return false;
return true;
}
@Override
public String toString() {
return "Foo [id=" + id + ", name=" + name + "]";
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/repository/IFooRepository.java
================================================
package org.springdoc.demo.resource.repository;
import org.springdoc.demo.resource.model.Foo;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface IFooRepository extends PagingAndSortingRepository<Foo, Long>, CrudRepository<Foo, Long> {
}
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/service/IFooService.java
================================================
package org.springdoc.demo.resource.service;
import java.util.Optional;
import org.springdoc.demo.resource.model.Foo;
public interface IFooService {
Optional<Foo> findById(Long id);
Foo save(Foo foo);
Iterable<Foo> findAll();
}
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/service/impl/FooServiceImpl.java
================================================
package org.springdoc.demo.resource.service.impl;
import java.util.Optional;
import org.springdoc.demo.resource.model.Foo;
import org.springdoc.demo.resource.repository.IFooRepository;
import org.springdoc.demo.resource.service.IFooService;
import org.springframework.stereotype.Service;
@Service
public class FooServiceImpl implements IFooService {
private IFooRepository fooRepository;
public FooServiceImpl(IFooRepository fooRepository) {
this.fooRepository = fooRepository;
}
@Override
public Optional<Foo> findById(Long id) {
return fooRepository.findById(id);
}
@Override
public Foo save(Foo foo) {
return fooRepository.save(foo);
}
@Override
public Iterable<Foo> findAll() {
return fooRepository.findAll();
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/web/controller/FooController.java
================================================
package org.springdoc.demo.resource.web.controller;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.demo.resource.model.Foo;
import org.springdoc.demo.resource.service.IFooService;
import org.springdoc.demo.resource.web.dto.FooDTO;
import org.springframework.http.HttpStatus;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;
@RestController
@RequestMapping(value = "/api/foos")
@SecurityRequirement(name = "security_auth")
public class FooController {
private IFooService fooService;
public FooController(IFooService fooService) {
this.fooService = fooService;
}
@GetMapping(value = "/{id}")
public FooDTO findOne(@PathVariable Long id) {
Foo entity = fooService.findById(id)
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
return convertToDto(entity);
}
@ResponseStatus(HttpStatus.CREATED)
@PostMapping
public void create(@RequestBody FooDTO newFoo) {
Foo entity = convertToEntity(newFoo);
this.fooService.save(entity);
}
@GetMapping
public Collection<FooDTO> findAll() {
Iterable<Foo> foos = this.fooService.findAll();
List<FooDTO> fooDtos = new ArrayList<>();
foos.forEach(p -> fooDtos.add(convertToDto(p)));
return fooDtos;
}
@PutMapping("/{id}")
public FooDTO updateFoo(@PathVariable("id") Long id, @RequestBody FooDTO updatedFoo) {
Foo fooEntity = convertToEntity(updatedFoo);
return this.convertToDto(this.fooService.save(fooEntity));
}
protected FooDTO convertToDto(Foo entity) {
FooDTO dto = new FooDTO(entity.getId(), entity.getName());
return dto;
}
protected Foo convertToEntity(FooDTO dto) {
Foo foo = new Foo(dto.getName());
if (!StringUtils.isEmpty(dto.getId())) {
foo.setId(dto.getId());
}
return foo;
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/web/controller/UserInfoController.java
================================================
package org.springdoc.demo.resource.web.controller;
import java.util.Collections;
import java.util.Map;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class UserInfoController {
@GetMapping("/user/info")
@SecurityRequirement(name = "security_auth")
public Map<String, Object> getUserInfo(@AuthenticationPrincipal Jwt principal) {
return Collections.singletonMap("user_name", principal.getClaimAsString("sub"));
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/web/dto/FooDTO.java
================================================
package org.springdoc.demo.resource.web.dto;
public class FooDTO {
private long id;
private String name;
public FooDTO() {
super();
}
public FooDTO(final long id, final String name) {
super();
this.id = id;
this.name = name;
}
//
public long getId() {
return id;
}
public void setId(final long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/resources/application.yml
================================================
server:
forward-headers-strategy: framework
port: 8082
####### resource server configuration properties
spring:
webflux:
base-path: /resource-server
jpa:
defer-datasource-initialization: true
security:
oauth2:
resourceserver:
jwt:
issuer-uri: ${OAUTH2_SERVER:http://127.0.0.1:8083}
springdoc:
version: '@springdoc.version@'
swagger-ui:
oauth:
clientId: newClient
clientSecret: newClientSecret
oAuthFlow:
authorizationUrl: ${OAUTH2_SERVER:http://127.0.0.1:8083}/oauth2/authorize
tokenUrl: ${OAUTH2_SERVER:http://127.0.0.1:8083}/oauth2/token
================================================
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/resources/data.sql
================================================
INSERT INTO Foo(id, name)
VALUES (1, 'Foo 1');
INSERT INTO Foo(id, name)
VALUES (2, 'Foo 2');
INSERT INTO Foo(id, name)
VALUES (3, 'Foo 3');
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/.gitignore
================================================
######################
# Project Specific
######################
/target/www/**
/src/test/javascript/coverage/
######################
# Node
######################
/node/
node_tmp/
node_modules/
npm-debug.log.*
/.awcache/*
/.cache-loader/*
######################
# SASS
######################
.sass-cache/
######################
# Eclipse
######################
*.pydevproject
.project
.metadata
tmp/
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
.factorypath
/src/main/resources/rebel.xml
# External tool builders
.externalToolBuilders/**
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
######################
# Intellij
######################
.idea/
*.iml
*.iws
*.ipr
*.ids
*.orig
classes/
out/
######################
# Visual Studio Code
######################
.vscode/
######################
# Maven
######################
/log/
/target/
######################
# Gradle
######################
.gradle/
/build/
######################
# Package Files
######################
*.jar
*.war
*.ear
*.db
######################
# Windows
######################
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
######################
# Mac OSX
######################
.DS_Store
.svn
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
######################
# Directories
######################
/bin/
/deploy/
######################
# Logs
######################
*.log*
######################
# Others
######################
*.class
*.*~
*~
.merge_file*
######################
# Gradle Wrapper
######################
!gradle/wrapper/gradle-wrapper.jar
######################
# Maven Wrapper
######################
!.mvn/wrapper/maven-wrapper.jar
######################
# ESLint
######################
.eslintcache
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/pom.xml
================================================
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springdoc</groupId>
<artifactId>demo-oauth2</artifactId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<artifactId>oauth-resource-server-webmvc</artifactId>
<dependencies>
<!-- web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
<!-- persistence -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<!-- OpenAPI 3 -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
</dependency>
</dependencies>
</project>
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/ResourceServerApp.java
================================================
package org.springdoc.demo.resource;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ResourceServerApp {
public static void main(String[] args) throws Exception {
SpringApplication.run(ResourceServerApp.class, args);
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/config/OpenApiConfig.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.resource.config;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.security.OAuthFlow;
import io.swagger.v3.oas.annotations.security.OAuthFlows;
import io.swagger.v3.oas.annotations.security.OAuthScope;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
@OpenAPIDefinition(info = @Info(title = "Foo API",
description = "Foo description", version = "v1"))
@SecurityScheme(name = "security_auth", type = SecuritySchemeType.OAUTH2,
flows = @OAuthFlows(authorizationCode = @OAuthFlow(
authorizationUrl = "${springdoc.oAuthFlow.authorizationUrl}"
, tokenUrl = "${springdoc.oAuthFlow.tokenUrl}", scopes = {
@OAuthScope(name = "springdoc.read", description = "read scope"),
@OAuthScope(name = "springdoc.write", description = "write scope") })))
public class OpenApiConfig {}
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/config/SecurityConfig.java
================================================
package org.springdoc.demo.resource.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain1(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(authz -> authz
.requestMatchers("/v3/api-docs/**", "/swagger-ui/**", "/swagger-ui.html").permitAll()
.requestMatchers(HttpMethod.GET, "/user/info", "/api/foos/**")
.hasAuthority("SCOPE_springdoc.read")
.requestMatchers(HttpMethod.POST, "/api/foos")
.hasAuthority("SCOPE_springdoc.write")
.anyRequest()
.authenticated())
.oauth2ResourceServer(oauth2 -> oauth2.jwt(Customizer.withDefaults()));
return http.build();
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/model/Foo.java
================================================
package org.springdoc.demo.resource.model;
import java.util.UUID;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@Entity
public class Foo {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
private UUID id;
private String name;
protected Foo() {
}
public Foo(String name) {
this.name = name;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Foo other = (Foo) obj;
if (id == null) {
if (other.id != null)
return false;
}
else if (!id.equals(other.id))
return false;
if (name == null) {
if (other.name != null)
return false;
}
else if (!name.equals(other.name))
return false;
return true;
}
@Override
public String toString() {
return "Foo [id=" + id + ", name=" + name + "]";
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/repository/IFooRepository.java
================================================
package org.springdoc.demo.resource.repository;
import org.springdoc.demo.resource.model.Foo;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface IFooRepository extends PagingAndSortingRepository<Foo, Long>, CrudRepository<Foo, Long> {
}
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/service/IFooService.java
================================================
package org.springdoc.demo.resource.service;
import java.util.Optional;
import org.springdoc.demo.resource.model.Foo;
public interface IFooService {
Optional<Foo> findById(Long id);
Foo save(Foo foo);
Iterable<Foo> findAll();
}
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/service/impl/FooServiceImpl.java
================================================
package org.springdoc.demo.resource.service.impl;
import java.util.Optional;
import org.springdoc.demo.resource.model.Foo;
import org.springdoc.demo.resource.repository.IFooRepository;
import org.springdoc.demo.resource.service.IFooService;
import org.springframework.stereotype.Service;
@Service
public class FooServiceImpl implements IFooService {
private IFooRepository fooRepository;
public FooServiceImpl(IFooRepository fooRepository) {
this.fooRepository = fooRepository;
}
@Override
public Optional<Foo> findById(Long id) {
return fooRepository.findById(id);
}
@Override
public Foo save(Foo foo) {
return fooRepository.save(foo);
}
@Override
public Iterable<Foo> findAll() {
return fooRepository.findAll();
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/web/controller/FooController.java
================================================
package org.springdoc.demo.resource.web.controller;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.demo.resource.model.Foo;
import org.springdoc.demo.resource.service.IFooService;
import org.springdoc.demo.resource.web.dto.FooDTO;
import org.springframework.http.HttpStatus;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;
@RestController
@RequestMapping(value = "/api/foos")
@SecurityRequirement(name = "security_auth")
public class FooController {
private IFooService fooService;
public FooController(IFooService fooService) {
this.fooService = fooService;
}
@GetMapping(value = "/{id}")
public FooDTO findOne(@PathVariable Long id) {
Foo entity = fooService.findById(id)
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
return convertToDto(entity);
}
@ResponseStatus(HttpStatus.CREATED)
@PostMapping
public void create(@RequestBody FooDTO newFoo) {
Foo entity = convertToEntity(newFoo);
this.fooService.save(entity);
}
@GetMapping
public Collection<FooDTO> findAll() {
Iterable<Foo> foos = this.fooService.findAll();
List<FooDTO> fooDtos = new ArrayList<>();
foos.forEach(p -> fooDtos.add(convertToDto(p)));
return fooDtos;
}
@PutMapping("/{id}")
public FooDTO updateFoo(@PathVariable("id") Long id, @RequestBody FooDTO updatedFoo) {
Foo fooEntity = convertToEntity(updatedFoo);
return this.convertToDto(this.fooService.save(fooEntity));
}
protected FooDTO convertToDto(Foo entity) {
FooDTO dto = new FooDTO(entity.getId(), entity.getName());
return dto;
}
protected Foo convertToEntity(FooDTO dto) {
Foo foo = new Foo(dto.getName());
if (!StringUtils.isEmpty(dto.getId())) {
foo.setId(dto.getId());
}
return foo;
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/web/controller/UserInfoController.java
================================================
package org.springdoc.demo.resource.web.controller;
import java.util.Collections;
import java.util.Map;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class UserInfoController {
@GetMapping("/user/info")
@SecurityRequirement(name = "security_auth")
public Map<String, Object> getUserInfo(@AuthenticationPrincipal Jwt principal) {
return Collections.singletonMap("user_name", principal.getClaimAsString("sub"));
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/web/dto/FooDTO.java
================================================
package org.springdoc.demo.resource.web.dto;
import java.util.UUID;
public class FooDTO {
private UUID id;
private String name;
public FooDTO() {
super();
}
public FooDTO(final UUID id, final String name) {
super();
this.id = id;
this.name = name;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
}
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/resources/application.yml
================================================
server:
port: 8081
forward-headers-strategy: framework
servlet:
context-path: /resource-server
####### resource server configuration properties
spring:
jpa:
defer-datasource-initialization: true
security:
oauth2:
resourceserver:
jwt:
issuer-uri: ${OAUTH2_SERVER:http://127.0.0.1:8083}
springdoc:
version: '@springdoc.version@'
swagger-ui:
oauth:
clientId: newClient
clientSecret: newClientSecret
oAuthFlow:
authorizationUrl: ${OAUTH2_SERVER:http://127.0.0.1:8083}/oauth2/authorize
tokenUrl: ${OAUTH2_SERVER:http://127.0.0.1:8083}/oauth2/token
================================================
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/resources/data.sql
================================================
INSERT INTO Foo(id, name)
VALUES ('dc58c780-a571-437e-85e2-9be232c5cd80', 'Foo 1');
INSERT INTO Foo(id, name)
VALUES ('dc58c780-a571-437e-85e2-9be232c5cd84', 'Foo 2');
INSERT INTO Foo(id, name)
VALUES ('dc58c780-a571-437e-85e2-9be232c5cd83', 'Foo 3');
================================================
FILE: demo-oauth2/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>springdoc-openapi-demos</artifactId>
<groupId>org.springdoc</groupId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<packaging>pom</packaging>
<artifactId>demo-oauth2</artifactId>
<modules>
<module>oauth-authorization-server</module>
<module>oauth-resource-server-webflux</module>
<module>oauth-resource-server-webmvc</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*LiveTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: demo-person-service/.gitattributes
================================================
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf
================================================
FILE: demo-person-service/.gitignore
================================================
######################
# Project Specific
######################
/target/www/**
/src/test/javascript/coverage/
######################
# Node
######################
/node/
node_tmp/
node_modules/
npm-debug.log.*
/.awcache/*
/.cache-loader/*
######################
# SASS
######################
.sass-cache/
######################
# Eclipse
######################
*.pydevproject
.project
.metadata
tmp/
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
.factorypath
/src/main/resources/rebel.xml
# External tool builders
.externalToolBuilders/**
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
######################
# Intellij
######################
.idea/
*.iml
*.iws
*.ipr
*.ids
*.orig
classes/
out/
######################
# Visual Studio Code
######################
.vscode/
######################
# Maven
######################
/log/
/target/
######################
# Gradle
######################
.gradle/
/build/
######################
# Package Files
######################
*.jar
*.war
*.ear
*.db
######################
# Windows
######################
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
######################
# Mac OSX
######################
.DS_Store
.svn
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
######################
# Directories
######################
/bin/
/deploy/
######################
# Logs
######################
*.log*
######################
# Others
######################
*.class
*.*~
*~
.merge_file*
######################
# Gradle Wrapper
######################
!gradle/wrapper/gradle-wrapper.jar
######################
# Maven Wrapper
######################
!.mvn/wrapper/maven-wrapper.jar
######################
# ESLint
######################
.eslintcache
================================================
FILE: demo-person-service/README.md
================================================
### Relevant Articles:
- [DZone Part1](https://dzone.com/articles/openapi-3-documentation-with-spring-boot)
- [DZone Part2](https://dzone.com/articles/doing-more-with-springdoc-openapi)
### Building native image with GraalVM
To create a `native image`, Run the following command
```sh
mvn -Pnative clean native:compile
```
================================================
FILE: demo-person-service/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>springdoc-openapi-demos</artifactId>
<groupId>org.springdoc</groupId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<description>Demo project for Spring Boot with openapi 3 documentation</description>
<artifactId>demo-person-service</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- OpenAPI 3 -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
</dependency>
<dependency>
<groupId>org.javamoney.moneta</groupId>
<artifactId>moneta-core</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>jackson-datatype-money</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/SampleApplication.java
================================================
package org.springdoc.demo.services.person;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication()
public class SampleApplication {
public static void main(String[] args) {
SpringApplication.run(SampleApplication.class, args);
}
@Bean
public OpenAPI customOpenAPI(@Value("${springdoc.version}") String appVersion) {
return new OpenAPI()
.components(new Components().addSecuritySchemes("basicScheme",
new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic")))
.info(new Info().title("Person API").version(appVersion)
.license(new License().name("Apache 2.0").url("http://springdoc.org")));
}
}
================================================
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/config/SampleConfig.java
================================================
package org.springdoc.demo.services.person.config;
import javax.money.MonetaryAmount;
import jakarta.annotation.PostConstruct;
import org.javamoney.moneta.Money;
import org.zalando.jackson.datatype.money.MoneyModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import static org.springdoc.core.utils.SpringDocUtils.getConfig;
@Configuration
public class SampleConfig {
@PostConstruct
public void initConfig() {
getConfig().replaceWithClass(MonetaryAmount.class,
org.springdoc.core.converters.models.MonetaryAmount.class);
}
@Bean
public MoneyModule moneyModule() {
return new MoneyModule().withMonetaryAmount(Money::of);
}
}
================================================
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/controller/PersonController.java
================================================
package org.springdoc.demo.services.person.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import org.springdoc.demo.services.person.model.Person;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class PersonController {
private Random ran = new Random();
@PostMapping("/persons")
public Person person(@Valid @RequestBody Person person) {
int nxt = ran.nextInt(10);
if (nxt >= 5) {
throw new RuntimeException("Breaking logic");
}
return person;
}
@GetMapping(path = "/persons")
public List<Person> findByLastName(@RequestParam @NotBlank @Size(max = 10) String lastName) {
List<Person> hardCoded = new ArrayList<>();
Person person = new Person();
person.setAge(20);
person.setEmail1("abc1@abc.com");
person.setEmail2("abc@abc.com");
person.setFirstName("Somefirstname");
person.setLastName(lastName);
person.setId(1);
hardCoded.add(person);
return hardCoded;
}
}
================================================
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/exceptions/ErrorMessage.java
================================================
package org.springdoc.demo.services.person.exceptions;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class ErrorMessage {
private List<String> errors;
public ErrorMessage() {
}
public ErrorMessage(List<String> errors) {
this.errors = errors;
}
public ErrorMessage(String error) {
this(Collections.singletonList(error));
}
public ErrorMessage(String... errors) {
this(Arrays.asList(errors));
}
public List<String> getErrors() {
return errors;
}
public void setErrors(List<String> errors) {
this.errors = errors;
}
}
================================================
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/exceptions/GlobalControllerAdvice.java
================================================
package org.springdoc.demo.services.person.exceptions;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.ConstraintViolationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.demo.services.person.controller.PersonController;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.validation.FieldError;
import org.springframework.validation.ObjectError;
import org.springframework.web.HttpMediaTypeNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
@ControllerAdvice(assignableTypes = PersonController.class)
public class GlobalControllerAdvice {
/**
* Note use base class if you wish to leverage its handling.
* Some code will need changing.
*/
private static final Logger logger = LoggerFactory.getLogger(GlobalControllerAdvice.class);
@ExceptionHandler(Throwable.class)
@ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR)
public ResponseEntity<Problem> problem(final Throwable e) {
String message = e.getMessage();
//might actually prefer to use a geeric mesasge
message = "Problem occured";
UUID uuid = UUID.randomUUID();
String logRef = uuid.toString();
logger.error("logRef=" + logRef, message, e);
return new ResponseEntity<Problem>(new Problem(logRef, message), HttpStatus.INTERNAL_SERVER_ERROR);
}
@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(code = HttpStatus.BAD_REQUEST)
public ResponseEntity<ErrorMessage> handleMethodArgumentNotValid(MethodArgumentNotValidException ex
) {
List<FieldError> fieldErrors = ex.getBindingResult().getFieldErrors();
List<ObjectError> globalErrors = ex.getBindingResult().getGlobalErrors();
List<String> errors = new ArrayList<>(fieldErrors.size() + globalErrors.size());
String error;
for (FieldError fieldError : fieldErrors) {
error = fieldError.getField() + ", " + fieldError.getDefaultMessage();
errors.add(error);
}
for (ObjectError objectError : globalErrors) {
error = objectError.getObjectName() + ", " + objectError.getDefaultMessage();
errors.add(error);
}
ErrorMessage errorMessage = new ErrorMessage(errors);
//Object result=ex.getBindingResult();//instead of above can allso pass the more detailed bindingResult
return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST);
}
@ExceptionHandler(ConstraintViolationException.class)
@ResponseStatus(code = HttpStatus.BAD_REQUEST)
public ResponseEntity<ErrorMessage> handleConstraintViolatedException(ConstraintViolationException ex
) {
Set<ConstraintViolation<?>> constraintViolations = ex.getConstraintViolations();
List<String> errors = new ArrayList<>(constraintViolations.size());
String error;
for (ConstraintViolation constraintViolation : constraintViolations) {
error = constraintViolation.getMessage();
errors.add(error);
}
ErrorMessage errorMessage = new ErrorMessage(errors);
return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST);
}
@ExceptionHandler(MissingServletRequestParameterException.class)
@ResponseStatus(code = HttpStatus.BAD_REQUEST)
public ResponseEntity<ErrorMessage> handleMissingServletRequestParameterException(MissingServletRequestParameterException ex
) {
List<String> errors = new ArrayList<>();
String error = ex.getParameterName() + ", " + ex.getMessage();
errors.add(error);
ErrorMessage errorMessage = new ErrorMessage(errors);
return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST);
}
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
@ResponseStatus(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE)
public ResponseEntity<ErrorMessage> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex
) {
String unsupported = "Unsupported content type: " + ex.getContentType();
String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes());
ErrorMessage errorMessage = new ErrorMessage(unsupported, supported);
return new ResponseEntity(errorMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE);
}
@ExceptionHandler(HttpMessageNotReadableException.class)
@ResponseStatus(code = HttpStatus.BAD_REQUEST)
public ResponseEntity<ErrorMessage> handleHttpMessageNotReadable(HttpMessageNotReadableException ex) {
ErrorMessage errorMessage = new ErrorMessage(ex.getMessage());
return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST);
}
}
================================================
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/exceptions/Problem.java
================================================
package org.springdoc.demo.services.person.exceptions;
public class Problem {
private String logRef;
private String message;
public Problem(String logRef, String message) {
super();
this.logRef = logRef;
this.message = message;
}
public Problem() {
super();
}
public String getLogRef() {
return logRef;
}
public void setLogRef(String logRef) {
this.logRef = logRef;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
================================================
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/model/Person.java
================================================
package org.springdoc.demo.services.person.model;
import javax.money.MonetaryAmount;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
public class Person {
private long id;
@Size(min = 2, max = 50)
@NotBlank
private String firstName;
@Size(min = 2, max = 50)
@NotBlank
private String lastName;
@Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address")
private String email1;
@Email
private String email2;
@Min(18)
@Max(30)
private int age;
@JsonProperty
private MonetaryAmount worth;
public MonetaryAmount getWorth() {
return worth;
}
public void setWorth(MonetaryAmount worth) {
this.worth = worth;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getEmail1() {
return email1;
}
public void setEmail1(String email1) {
this.email1 = email1;
}
public String getEmail2() {
return email2;
}
public void setEmail2(String email2) {
this.email2 = email2;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
================================================
FILE: demo-person-service/src/main/resources/application.properties
================================================
springdoc.version=@springdoc.version@
springdoc.swagger-ui.use-root-path=true
server.forward-headers-strategy=framework
================================================
FILE: demo-spring-boot-3-webflux/.gitignore
================================================
######################
# Project Specific
######################
/target/www/**
/src/test/javascript/coverage/
######################
# Node
######################
/node/
node_tmp/
node_modules/
npm-debug.log.*
/.awcache/*
/.cache-loader/*
######################
# SASS
######################
.sass-cache/
######################
# Eclipse
######################
*.pydevproject
.project
.metadata
tmp/
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
.factorypath
/src/main/resources/rebel.xml
# External tool builders
.externalToolBuilders/**
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
######################
# Intellij
######################
.idea/
*.iml
*.iws
*.ipr
*.ids
*.orig
classes/
out/
######################
# Visual Studio Code
######################
.vscode/
######################
# Maven
######################
/log/
/target/
######################
# Gradle
######################
.gradle/
/build/
######################
# Package Files
######################
*.jar
*.war
*.ear
*.db
######################
# Windows
######################
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
######################
# Mac OSX
######################
.DS_Store
.svn
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
######################
# Directories
######################
/bin/
/deploy/
######################
# Logs
######################
*.log*
######################
# Others
######################
*.class
*.*~
*~
.merge_file*
######################
# Gradle Wrapper
######################
!gradle/wrapper/gradle-wrapper.jar
######################
# Maven Wrapper
######################
!.mvn/wrapper/maven-wrapper.jar
######################
# ESLint
######################
.eslintcache
================================================
FILE: demo-spring-boot-3-webflux/.java-version
================================================
graalvm64-17.0.5
================================================
FILE: demo-spring-boot-3-webflux/README.md
================================================
# springdoc-openapi demo with spring-boot-2 web-flux
## Building application
### Pre-requisites
- JDK 8+
- maven 3
- docker CLI
### Option 1: Building Executable JAR
To create an `executable jar`, simply run:
```sh
mvn clean package
```
### Option 2: Building a non-native OCI Images
To create a non-native OCI docker image, simply run:
```sh
mvn clean spring-boot:build-image
```
### Option 3: Building native image with GraalVM
To create a `native image`, Run the following command
```sh
mvn -Pnative clean native:compile
```
## Running the native application
To run the demo using docker, invoke the following:
```sh
docker run --rm -p 8080:8082 springdoc-openapi-spring-boot-2-webflux:3.1.6-SNAPSHOT
```
================================================
FILE: demo-spring-boot-3-webflux/pom.xml
================================================
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-demos</artifactId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<artifactId>demo-spring-boot-3-webflux</artifactId>
<dependencies>
<!-- springdoc ui -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
</dependency>
<!-- webflux -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<configuration>
<apiDocsUrl>http://localhost:8080/v3/api-docs.yaml</apiDocsUrl>
<outputFileName>openapi.yaml</outputFileName>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>-Dspring.application.admin.enabled=true</jvmArguments>
</configuration>
<executions>
<execution>
<goals>
<goal>start</goal>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/WebfluxDemoApplication.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.app3;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories;
@SpringBootApplication
@EnableReactiveMongoRepositories
public class WebfluxDemoApplication {
public static void main(String[] args) {
SpringApplication.run(WebfluxDemoApplication.class, args);
}
@Bean
public OpenAPI customOpenAPI(@Value("${springdoc.version}") String appVersion) {
return new OpenAPI()
.components(new Components().addSecuritySchemes("basicScheme",
new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic")))
.info(new Info().title("Tweet API").version(appVersion)
.license(new License().name("Apache 2.0").url("http://springdoc.org")));
}
@Bean
public GroupedOpenApi storeOpenApi() {
String[] paths = { "/tweets/**" };
return GroupedOpenApi.builder().group("tweets").pathsToMatch(paths)
.build();
}
@Bean
public GroupedOpenApi userOpenApi() {
String[] paths = { "/stream/**" };
String[] packagedToMatch = { "org.springdoc.demo.app3" };
return GroupedOpenApi.builder().group("x-stream").pathsToMatch(paths).packagesToScan(packagedToMatch)
.build();
}
}
================================================
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/controller/ExceptionTranslator.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.app3.controller;
import org.springdoc.demo.app3.exception.TweetNotFoundException;
import org.springdoc.demo.app3.payload.ErrorResponse;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice
public class ExceptionTranslator {
@SuppressWarnings("rawtypes")
@ExceptionHandler(DuplicateKeyException.class)
@ResponseStatus(HttpStatus.CONFLICT)
public ResponseEntity handleDuplicateKeyException(DuplicateKeyException ex) {
return ResponseEntity.status(HttpStatus.CONFLICT)
.body(new ErrorResponse("A Tweet with the same text already exists"));
}
@SuppressWarnings("rawtypes")
@ExceptionHandler(TweetNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public ResponseEntity handleTweetNotFoundException(TweetNotFoundException ex) {
return ResponseEntity.notFound().build();
}
}
================================================
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/controller/TweetController.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.app3.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Valid;
import org.springdoc.demo.app3.dto.TweetDTO;
import org.springdoc.demo.app3.model.Tweet;
import org.springdoc.demo.app3.repository.TweetRepository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
/**
* Created by bnasslahsen
*/
@RestController
public class TweetController {
private final TweetRepository tweetRepository;
private final TweetMapper tweetMapper;
public TweetController(TweetRepository tweetRepository, TweetMapper tweetMapper) {
this.tweetRepository = tweetRepository;
this.tweetMapper = tweetMapper;
}
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get All Tweets") })
@GetMapping("/tweets")
public Flux<TweetDTO> getAllTweets() {
Flux<Tweet> tweet = tweetRepository.findAll();
return tweetMapper.toDTO(tweet);
}
@PostMapping("/tweets")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "create Tweets") })
public Mono<TweetDTO> createTweets(@Valid @RequestBody TweetDTO tweetDTO) {
return tweetRepository.save(tweetMapper.toEntity(tweetDTO)).map(tweetMapper::toDTO);
}
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get Tweet By Id"),
@ApiResponse(responseCode = "404", description = "tweet not found") })
@GetMapping("/tweets/{id}")
public Mono<ResponseEntity<TweetDTO>> getTweetById(@PathVariable(value = "id") String tweetId) {
return tweetRepository.findById(tweetId).map(savedTweet -> ResponseEntity.ok(tweetMapper.toDTO(savedTweet)))
.defaultIfEmpty(ResponseEntity.notFound().build());
}
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "update Tweet"),
@ApiResponse(responseCode = "404", description = "tweet not found") })
@PutMapping("/tweets/{id}")
public Mono<ResponseEntity<TweetDTO>> updateTweet(@PathVariable(value = "id") String tweetId,
@Valid @RequestBody TweetDTO tweetDTO) {
return tweetRepository.findById(tweetId).flatMap(existingTweet -> {
existingTweet.setText(tweetMapper.toEntity(tweetDTO).getText());
return tweetRepository.save(existingTweet);
}).map(updateTweet -> new ResponseEntity<>(tweetMapper.toDTO(updateTweet), HttpStatus.OK))
.defaultIfEmpty(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "delete Tweet"),
@ApiResponse(responseCode = "404", description = "tweet not found") })
@DeleteMapping("/tweets/{id}")
public Mono<ResponseEntity<Void>> deleteTweet(@PathVariable(value = "id") String tweetId) {
return tweetRepository.findById(tweetId)
.flatMap(existingTweet -> tweetRepository.delete(existingTweet)
.then(Mono.just(new ResponseEntity<Void>(HttpStatus.OK))))
.defaultIfEmpty(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}
@Operation(description = "Tweets are Sent to the client as Server Sent Events", responses = {
@ApiResponse(responseCode = "200", description = "stream All Tweets") })
@GetMapping(value = "/stream/tweets", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<TweetDTO> streamAllTweets() {
return tweetMapper.toDTO(tweetRepository.findAll());
}
}
================================================
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/controller/TweetMapper.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.app3.controller;
import org.springdoc.demo.app3.dto.TweetDTO;
import org.springdoc.demo.app3.model.Tweet;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
@Component
public class TweetMapper {
Flux<TweetDTO> toDTO(Flux<Tweet> tweet) {
return tweet.map(this::toDTO);
}
Flux<Tweet> toEntity(Flux<TweetDTO> tweetDTO) {
return tweetDTO.map(this::toEntity);
}
Mono<TweetDTO> toDTO(Mono<Tweet> tweet) {
return tweet.map(this::toDTO);
}
Mono<Tweet> toEntity(Mono<TweetDTO> tweetDTO) {
return tweetDTO.map(this::toEntity);
}
TweetDTO toDTO(Tweet tweet) {
TweetDTO teTweetDTO = new TweetDTO();
BeanUtils.copyProperties(tweet,teTweetDTO);
return teTweetDTO;
}
Tweet toEntity(TweetDTO tweetDTO) {
Tweet teTweet = new Tweet();
BeanUtils.copyProperties(tweetDTO, teTweet);
return teTweet;
}
}
================================================
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/dto/TweetDTO.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.app3.dto;
import java.util.Date;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
/**
* Created by bnasslahsen on 08/09/17.
*/
public class TweetDTO {
private String id;
@NotBlank
@Size(max = 140)
private String text;
@NotNull
private Date createdAt = new Date();
public TweetDTO() {
}
public TweetDTO(String text) {
this.text = text;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
}
================================================
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/exception/TweetNotFoundException.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.app3.exception;
/**
* Created by bnasslahsen
*/
public class TweetNotFoundException extends RuntimeException {
/**
*
*/
private static final long serialVersionUID = 1L;
public TweetNotFoundException(String tweetId) {
super("Tweet not found with id " + tweetId);
}
}
================================================
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/model/Tweet.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.app3.model;
import java.util.Date;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* Created by bnasslahsen on 08/09/17.
*/
@Document(collection = "tweets")
public class Tweet {
@Id
private String id;
@NotBlank
@Size(max = 140)
private String text;
@NotNull
private Date createdAt = new Date();
public Tweet() {
}
public Tweet(String text) {
this.text = text;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
}
================================================
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/payload/ErrorResponse.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.app3.payload;
/**
* Created by bnasslahsen
*/
public class ErrorResponse {
private String message;
public ErrorResponse(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
================================================
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/repository/TweetRepository.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.app3.repository;
import org.springdoc.demo.app3.model.Tweet;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.stereotype.Repository;
/**
* Created by bnasslahsen on 08/09/17.
*/
@Repository
public interface TweetRepository extends ReactiveMongoRepository<Tweet, String> {
}
================================================
FILE: demo-spring-boot-3-webflux/src/main/resources/META-INF/native-image/reflect-config.json
================================================
[
{
"name": "org.springdoc.demo.app3.dto.TweetDTO[]"
}
]
================================================
FILE: demo-spring-boot-3-webflux/src/main/resources/application.yml
================================================
server:
port: 8082
forward-headers-strategy: framework
spring:
data:
mongodb:
uri: ${SPRING_DATA_MONGODB_URI:mongodb://localhost:27017/tweetsdb}
springdoc:
version: '@springdoc.version@'
swagger-ui:
use-root-path: true
================================================
FILE: demo-spring-boot-3-webflux-functional/.gitignore
================================================
######################
# Project Specific
######################
/target/www/**
/src/test/javascript/coverage/
######################
# Node
######################
/node/
node_tmp/
node_modules/
npm-debug.log.*
/.awcache/*
/.cache-loader/*
######################
# SASS
######################
.sass-cache/
######################
# Eclipse
######################
*.pydevproject
.project
.metadata
tmp/
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
.factorypath
/src/main/resources/rebel.xml
# External tool builders
.externalToolBuilders/**
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
######################
# Intellij
######################
.idea/
*.iml
*.iws
*.ipr
*.ids
*.orig
classes/
out/
######################
# Visual Studio Code
######################
.vscode/
######################
# Maven
######################
/log/
/target/
######################
# Gradle
######################
.gradle/
/build/
######################
# Package Files
######################
*.jar
*.war
*.ear
*.db
######################
# Windows
######################
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
######################
# Mac OSX
######################
.DS_Store
.svn
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
######################
# Directories
######################
/bin/
/deploy/
######################
# Logs
######################
*.log*
######################
# Others
######################
*.class
*.*~
*~
.merge_file*
######################
# Gradle Wrapper
######################
!gradle/wrapper/gradle-wrapper.jar
######################
# Maven Wrapper
######################
!.mvn/wrapper/maven-wrapper.jar
######################
# ESLint
######################
.eslintcache
================================================
FILE: demo-spring-boot-3-webflux-functional/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>springdoc-openapi-demos</artifactId>
<groupId>org.springdoc</groupId>
<version>3.1.7-SNAPSHOT</version>
</parent>
<artifactId>demo-spring-boot-3-webflux-functional</artifactId>
<dependencies>
<!-- springdoc ui -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
</dependency>
<!-- webflux -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-r2dbc</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/AppNativeConfiguration.java
================================================
package org.springdoc.demo.app4;
import java.util.Arrays;
import org.springdoc.demo.app4.AppNativeConfiguration.AppNativeRuntimeHints;
import org.springdoc.demo.app4.coffee.CoffeeService;
import org.springdoc.demo.app4.employee.EmployeeRepository;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportRuntimeHints;
/**
* @author bnasslahsen
*/
@Configuration
@ImportRuntimeHints(AppNativeRuntimeHints.class)
public class AppNativeConfiguration {
static Class[] applicationClasses = { org.springdoc.demo.app4.user.User[].class,
org.springdoc.demo.app4.employee.Employee[].class,
org.springdoc.demo.app4.coffee.Coffee[].class,
org.springdoc.demo.app4.coffee.CoffeeOrder[].class,
EmployeeRepository.class,
CoffeeService.class
};
static class AppNativeRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
Arrays.stream(applicationClasses).forEach(applicationClass ->
hints.reflection().registerType(applicationClass,
(hint) -> hint.withMembers(MemberCategory.DECLARED_FIELDS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS)));
}
}
}
================================================
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/WebfluxFunctionalDemoApplication.java
================================================
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package org.springdoc.demo.app4;
import io.swagger.v3.oas.models.info.Info;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class WebfluxFunctionalDemoApplication {
public static void main(String[] args) {
SpringApplication.run(WebfluxFunctionalDemoApplication.class, args);
}
@Bean
public GroupedOpenApi employeesOpenApi(@Value("${springdoc.version}") String appVersion) {
String[] paths = { "/employees/**" };
return GroupedOpenApi.builder().group("employees")
.addOpenApiCustomizer(openApi -> openApi.info(new Info().title("Employees API").version(appVersion)))
.pathsToMatch(paths)
.build();
}
@Bean
public GroupedOpenApi userOpenApi(@Value("${springdoc.version}") String appVersion) {
String[] paths = { "/api/user/**" };
return GroupedOpenApi.builder().group("users")
.addOpenApiCustomizer(openApi -> openApi.info(new Info().title("Users API").version(appVersion)))
.pathsToMatch(paths)
.build();
}
@Bean
public GroupedOpenApi coffeeOpenApi(@Value("${springdoc.version}") String appVersion) {
String[] paths = { "/coffees/**" };
return GroupedOpenApi.builder().group("coffees")
.addOpenApiCustomizer(openApi -> openApi.info(new Info().title("Coffees API").version(appVersion)))
.pathsToMatch(paths)
.build();
}
}
================================================
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/Coffee.java
================================================
package org.springdoc.demo.app4.coffee;
import java.util.Objects;
import org.springframework.data.annotation.Id;
public class Coffee {
@Id
private String id;
private String name;
public Coffee() {
}
public Coffee(String name) {
this.name = name;
}
public Coffee(String id, String name) {
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Coffee coffee = (Coffee) o;
return Objects.equals(id, coffee.id) &&
Objects.equals(name, coffee.name);
}
@Override
public int hashCode() {
return Objects.hash(id, name);
}
@Override
public String toString() {
return "Coffee{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
'}';
}
}
================================================
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/CoffeeOrder.java
================================================
package org.springdoc.demo.app4.coffee;
import java.time.Instant;
import java.util.Objects;
public class CoffeeOrder {
private String coffeeId;
private Instant whenOrdered;
public CoffeeOrder() {
}
public CoffeeOrder(String coffeeId, Instant whenOrdered) {
this.coffeeId = coffeeId;
this.whenOrdered = whenOrdered;
}
public String getCoffeeId() {
return coffeeId;
}
public Instant getWhenOrdered() {
return whenOrdered;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CoffeeOrder that = (CoffeeOrder) o;
return Objects.equals(coffeeId, that.coffeeId) &&
Objects.equals(whenOrdered, that.whenOrdered);
}
@Override
public int hashCode() {
return Objects.hash(coffeeId, whenOrdered);
}
@Override
public String toString() {
return "CoffeeOrder{" +
"coffeeId='" + coffeeId + '\'' +
", whenOrdered=" + whenOrdered +
'}';
}
}
================================================
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/CoffeeRepository.java
================================================
package org.springdoc.demo.app4.coffee;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
public interface CoffeeRepository extends ReactiveCrudRepository<Coffee, String> {
}
================================================
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/CoffeeService.java
================================================
package org.springdoc.demo.app4.coffee;
import java.time.Duration;
import java.time.Instant;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.stereotype.Service;
@Service
public class CoffeeService {
private final CoffeeRepository repo;
public CoffeeService(CoffeeRepository repo) {
this.repo = repo;
}
Flux<Coffee> getAllCoffees() {
return repo.findAll();
}
Mono<Coffee> getCoffeeById(@Parameter(in = ParameterIn.PATH) String id) {
return repo.findById(id);
}
Flux<CoffeeOrder> getOrdersForCoffeeById(@Parameter(in = ParameterIn.PATH) String coffeeId) {
return Flux.interval(Duration.ofSeconds(1))
.onBackpressureDrop()
.map(i -> new CoffeeOrder(coffeeId, Instant.now()));
}
}
================================================
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/RouteConfig.java
================================================
package org.springdoc.demo.app4.coffee;
import reactor.core.publisher.Mono;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route;
@Configuration
public class RouteConfig {
private final CoffeeService service;
public RouteConfig(CoffeeService service) {
this.service = service;
}
@Bean
RouterFunction<ServerResponse> routerFunction() {
return route().GET("/coffees", this::all, ops -> ops.beanClass(CoffeeService.class).beanMethod("getAllCoffees")).build()
.and(route().GET("/coffees/{id}", this::byId, ops -> ops.beanClass(CoffeeService.class).beanMethod("getCoffeeById")).build())
.and(route().GET("/coffees/{id}/orders", this::orders, ops -> ops.beanClass(CoffeeService.class).beanMethod("getOrdersForCoffeeById")).build());
}
private Mono<ServerResponse> all(ServerRequest req) {
return ServerResponse.ok()
.body(service.getAllCoffees(), Coffee.class);
}
private Mono<ServerResponse> byId(ServerRequest req) {
return ServerResponse.ok()
.body(service.getCoffeeById(req.pathVariable("id")), Coffee.class);
}
private Mono<ServerResponse> orders(ServerRequest req) {
return ServerResponse.ok()
.contentType(MediaType.TEXT_EVENT_STREAM)
.body(service.getOrdersForCoffeeById(req.pathVariable("id")), CoffeeOrder.class);
}
}
================================================
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/employee/Employee.java
================================================
package org.springdoc.demo.app4.employee;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Employee {
private String id;
private String name;
// standard getters and setters
}
================================================
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/employee/EmployeeFunctionalConfig.java
================================================
package org.springdoc.demo.app4.employee;
import java.util.function.Consumer;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import org.springdoc.core.fn.builders.operation.Builder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.BodyExtractors;
import org.springframework.web.reactive.function.server.HandlerFunction;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;
import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder;
import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder;
import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route;
import static org.springframework.web.reactive.function.server.RequestPredicates.accept;
import static org.springframework.web.reactive.function.server.ServerResponse.ok;
@Configuration
public class EmployeeFunctionalConfig {
@Bean
EmployeeRepository employeeRepository() {
return new EmployeeRepository();
}
@Bean
RouterFunction<ServerResponse> getAllEmployeesRoute() {
return route()
.GET("/employees", accept(MediaType.APPLICATION_JSON),
findAllEmployeesFunction(), getOpenAPI("findAllEmployees")).build();
}
@Bean
RouterFunction<ServerResponse> getEmployeeByIdRoute() {
return route().GET("/employees/{id}", findEmployeeByIdFunction(), findEmployeeByIdOpenAPI()).build();
}
@Bean
RouterFunction<ServerResponse> updateEmployeeRoute() {
return route().POST("/employees/update", accept(MediaType.APPLICATION_XML),
updateEmployeeFunction(), getOpenAPI("updateEmployee")).build();
}
RouterFunction<ServerResponse> composedRoutes() {
return route().GET("/employees-composed", findAllEmployeesFunction(), getOpenAPI("findAllEmployees")).build()
.and(route().GET("/employees-composed/{id}", findEmployeeByIdFunction(), findEmployeeByIdOpenAPI()).build())
.and(route().POST("/employees-composed/update", updateEmployeeFunction(), getOpenAPI("updateEmployee")).build());
}
private HandlerFunction<ServerResponse> findAllEmployeesFunction() {
return req -> ok().body(
employeeRepository().findAllEmployees(), Employee.class);
}
private HandlerFunction<ServerResponse> updateEmployeeFunction() {
return req -> req.body(BodyExtractors.toMono(Employee.class))
.doOnNext(employeeRepository()::updateEmployee)
.then(ok().build());
}
private HandlerFunction<ServerResponse> findEmployeeByIdFunction() {
return req -> ok().body(
employeeRepository().findEmployeeById(req.pathVariable("id")), Employee.class);
}
private Consumer<Builder> getOpenAPI(String findAllEmployees) {
return ops -> ops.beanClass(EmployeeRepository.class).beanMethod(findAllEmployees);
}
private Consumer<Builder> findEmployeeByIdOpenAPI() {
return ops -> ops.tag("employee")
.operationId("findEmployeeById").summary("Find purchase order by ID").tags(new String[] { "MyEmployee" })
.parameter(parameterBuilder().in(ParameterIn.PATH).name("id").description("Employee Id"))
.response(responseBuilder().responseCode("200").description("successful operation").implementation(Employee.class))
.response(responseBuilder().responseCode("400").description("Invalid Employee ID supplied"))
.response(responseBuilder().responseCode("404").description("Employee not found"));
}
}
================================================
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/employee/EmployeeRepository.java
================================================
package org.springdoc.demo.app4.employee;
import java.util.HashMap;
import java.util.Map;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@Tag(name = "Employees")
public class EmployeeRepository {
static Map<String, Employee> employeeData;
static Map<String, String> employeeAccessData;
static {
employeeData = new HashMap<>();
employeeData.put("1", new Employee("1", "Employee 1"));
employeeData.put("2", new Employee("2", "Employee 2"));
employeeData.put("3", new Employee("3", "Employee 3"));
employeeData.put("4", new Employee("4", "Employee 4"));
employeeData.put("5", new Employee("5", "Employee 5"));
employeeData.put("6", new Employee("6", "Employee 6"));
employeeData.put("7", new Employee("7", "Employee 7"));
employeeData.put("8", new Employee("8", "Employee 8"));
employeeData.put("9", new Employee("9", "Employee 9"));
employeeData.put("10", new Employee("10", "Employee 10"));
employeeAccessData = new HashMap<>();
employeeAccessData.put("1", "Employee 1 Access Key");
employeeAccessData.put("2", "Employee 2 Access Key");
employeeAccessData.put("3", "Employee 3 Access Key");
employeeAccessData.put("4", "Employee 4 Access Key");
employeeAccessData.put("5", "Employee 5 Access Key");
employeeAccessData.put("6", "Employee 6 Access Key");
employeeAccessData.put("7", "Employee 7 Access Key");
employeeAccessData.put("8", "Employee 8 Access Key");
employeeAccessData.put("9", "Employee 9 Access Key");
employeeAccessData.put("10", "Employee 10 Access Key");
}
public Mono<Employee> findEmployeeById(@Parameter(in = ParameterIn.PATH) String id) {
return Mono.just(employeeData.get(id));
}
public Flux<Employee> findAllEmployees() {
return Flux.fromIterable(employeeData.values());
}
public Mono<Employee> updateEmployee(Employee employee) {
Employee existingEmployee = employeeData.get(employee.getId());
if (existingEmployee != null) {
existingEmployee.setName(employee.getName());
}
return Mono.just(existingEmployee);
}
}
================================================
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/user/RoutingConfiguration.java
================================================
package org.springdoc.demo.app4.user;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;
import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route;
import static o
gitextract_h9gh0xwv/ ├── .gitattributes ├── .gitignore ├── Jenkinsfile ├── LICENSE ├── README.md ├── SUPPORT.md ├── demo-book-service/ │ ├── .gitignore │ ├── README.md │ ├── pom.xml │ └── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── springdoc/ │ │ │ └── demo/ │ │ │ └── services/ │ │ │ └── book/ │ │ │ ├── SpringdocApplication.java │ │ │ ├── controller/ │ │ │ │ └── BookController.java │ │ │ ├── exception/ │ │ │ │ ├── BookNotFoundException.java │ │ │ │ └── GlobalControllerExceptionHandler.java │ │ │ ├── model/ │ │ │ │ └── Book.java │ │ │ └── repository/ │ │ │ └── BookRepository.java │ │ └── resources/ │ │ ├── application.yml │ │ └── logback.xml │ └── test/ │ └── java/ │ └── org/ │ └── springdoc/ │ └── demo/ │ └── services/ │ └── book/ │ └── SwaggerUnitTest.java ├── demo-microservices/ │ ├── .gitignore │ ├── README.md │ ├── config-service/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── springdoc/ │ │ │ └── demo/ │ │ │ └── services/ │ │ │ └── config/ │ │ │ └── ConfigApplication.java │ │ └── resources/ │ │ ├── application.yml │ │ └── config/ │ │ ├── department-service.yml │ │ ├── discovery-service.yml │ │ ├── employee-service.yml │ │ ├── gateway-service.yml │ │ └── organization-service.yml │ ├── department-service/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── springdoc/ │ │ │ └── demo/ │ │ │ └── services/ │ │ │ └── department/ │ │ │ ├── DepartmentApplication.java │ │ │ ├── client/ │ │ │ │ └── EmployeeClient.java │ │ │ ├── controller/ │ │ │ │ └── DepartmentController.java │ │ │ ├── model/ │ │ │ │ ├── Department.java │ │ │ │ └── Employee.java │ │ │ └── repository/ │ │ │ └── DepartmentRepository.java │ │ └── resources/ │ │ └── application.yml │ ├── discovery-service/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── springdoc/ │ │ │ └── demo/ │ │ │ └── services/ │ │ │ └── discovery/ │ │ │ └── DiscoveryApplication.java │ │ └── resources/ │ │ └── application.yml │ ├── employee-service/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── springdoc/ │ │ │ └── demo/ │ │ │ └── services/ │ │ │ └── employee/ │ │ │ ├── EmployeeApplication.java │ │ │ ├── controller/ │ │ │ │ └── EmployeeController.java │ │ │ ├── model/ │ │ │ │ └── Employee.java │ │ │ └── repository/ │ │ │ └── EmployeeRepository.java │ │ └── resources/ │ │ └── application.yml │ ├── gateway-service/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── springdoc/ │ │ │ └── demo/ │ │ │ └── services/ │ │ │ └── gateway/ │ │ │ ├── ContextPathRewritePathGatewayFilterFactory.java │ │ │ └── GatewayApplication.java │ │ └── resources/ │ │ └── application.yml │ ├── organization-service/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── springdoc/ │ │ │ └── demo/ │ │ │ └── services/ │ │ │ └── organization/ │ │ │ ├── OrganizationApplication.java │ │ │ ├── client/ │ │ │ │ ├── DepartmentClient.java │ │ │ │ └── EmployeeClient.java │ │ │ ├── controller/ │ │ │ │ └── OrganizationController.java │ │ │ ├── model/ │ │ │ │ ├── Department.java │ │ │ │ ├── Employee.java │ │ │ │ └── Organization.java │ │ │ └── repository/ │ │ │ └── OrganizationRepository.java │ │ └── resources/ │ │ └── application.yml │ └── pom.xml ├── demo-oauth2/ │ ├── .gitignore │ ├── README.md │ ├── oauth-authorization-server/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── springdoc/ │ │ │ └── demo/ │ │ │ └── auth/ │ │ │ ├── AuthorizationServerApp.java │ │ │ ├── DefaultSecurityConfig.java │ │ │ ├── Jwks.java │ │ │ ├── KeyGeneratorUtils.java │ │ │ └── SecurityConfig.java │ │ └── resources/ │ │ └── application.yml │ ├── oauth-resource-server-webflux/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── springdoc/ │ │ │ └── demo/ │ │ │ └── resource/ │ │ │ ├── ResourceServerApp.java │ │ │ ├── config/ │ │ │ │ ├── OpenApiConfig.java │ │ │ │ └── SecurityConfig.java │ │ │ ├── model/ │ │ │ │ └── Foo.java │ │ │ ├── repository/ │ │ │ │ └── IFooRepository.java │ │ │ ├── service/ │ │ │ │ ├── IFooService.java │ │ │ │ └── impl/ │ │ │ │ └── FooServiceImpl.java │ │ │ └── web/ │ │ │ ├── controller/ │ │ │ │ ├── FooController.java │ │ │ │ └── UserInfoController.java │ │ │ └── dto/ │ │ │ └── FooDTO.java │ │ └── resources/ │ │ ├── application.yml │ │ └── data.sql │ ├── oauth-resource-server-webmvc/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── springdoc/ │ │ │ └── demo/ │ │ │ └── resource/ │ │ │ ├── ResourceServerApp.java │ │ │ ├── config/ │ │ │ │ ├── OpenApiConfig.java │ │ │ │ └── SecurityConfig.java │ │ │ ├── model/ │ │ │ │ └── Foo.java │ │ │ ├── repository/ │ │ │ │ └── IFooRepository.java │ │ │ ├── service/ │ │ │ │ ├── IFooService.java │ │ │ │ └── impl/ │ │ │ │ └── FooServiceImpl.java │ │ │ └── web/ │ │ │ ├── controller/ │ │ │ │ ├── FooController.java │ │ │ │ └── UserInfoController.java │ │ │ └── dto/ │ │ │ └── FooDTO.java │ │ └── resources/ │ │ ├── application.yml │ │ └── data.sql │ └── pom.xml ├── demo-person-service/ │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── org/ │ │ └── springdoc/ │ │ └── demo/ │ │ └── services/ │ │ └── person/ │ │ ├── SampleApplication.java │ │ ├── config/ │ │ │ └── SampleConfig.java │ │ ├── controller/ │ │ │ └── PersonController.java │ │ ├── exceptions/ │ │ │ ├── ErrorMessage.java │ │ │ ├── GlobalControllerAdvice.java │ │ │ └── Problem.java │ │ └── model/ │ │ └── Person.java │ └── resources/ │ └── application.properties ├── demo-spring-boot-3-webflux/ │ ├── .gitignore │ ├── .java-version │ ├── README.md │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── org/ │ │ └── springdoc/ │ │ └── demo/ │ │ └── app3/ │ │ ├── WebfluxDemoApplication.java │ │ ├── controller/ │ │ │ ├── ExceptionTranslator.java │ │ │ ├── TweetController.java │ │ │ └── TweetMapper.java │ │ ├── dto/ │ │ │ └── TweetDTO.java │ │ ├── exception/ │ │ │ └── TweetNotFoundException.java │ │ ├── model/ │ │ │ └── Tweet.java │ │ ├── payload/ │ │ │ └── ErrorResponse.java │ │ └── repository/ │ │ └── TweetRepository.java │ └── resources/ │ ├── META-INF/ │ │ └── native-image/ │ │ └── reflect-config.json │ └── application.yml ├── demo-spring-boot-3-webflux-functional/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── org/ │ │ └── springdoc/ │ │ └── demo/ │ │ └── app4/ │ │ ├── AppNativeConfiguration.java │ │ ├── WebfluxFunctionalDemoApplication.java │ │ ├── coffee/ │ │ │ ├── Coffee.java │ │ │ ├── CoffeeOrder.java │ │ │ ├── CoffeeRepository.java │ │ │ ├── CoffeeService.java │ │ │ └── RouteConfig.java │ │ ├── employee/ │ │ │ ├── Employee.java │ │ │ ├── EmployeeFunctionalConfig.java │ │ │ └── EmployeeRepository.java │ │ └── user/ │ │ ├── RoutingConfiguration.java │ │ ├── User.java │ │ ├── UserHandler.java │ │ ├── UserRepository.java │ │ └── UserRepositoryImpl.java │ └── resources/ │ ├── application.yml │ ├── logback-spring.xml │ └── schema.sql ├── demo-spring-boot-3-webmvc/ │ ├── .gitignore │ ├── .java-version │ ├── README.md │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── org/ │ │ └── springdoc/ │ │ └── demo/ │ │ └── app2/ │ │ ├── Application.java │ │ ├── api/ │ │ │ ├── ApiUtil.java │ │ │ ├── ExceptionTranslator.java │ │ │ ├── PetApi.java │ │ │ ├── PetApiController.java │ │ │ ├── PetApiDelegate.java │ │ │ ├── PetApiDelegateImpl.java │ │ │ ├── StoreApi.java │ │ │ ├── StoreApiController.java │ │ │ ├── StoreApiDelegate.java │ │ │ ├── StoreApiDelegateImpl.java │ │ │ ├── UserApi.java │ │ │ ├── UserApiController.java │ │ │ ├── UserApiDelegate.java │ │ │ └── UserApiDelegateImpl.java │ │ ├── model/ │ │ │ ├── Body.java │ │ │ ├── Body1.java │ │ │ ├── Category.java │ │ │ ├── ModelApiResponse.java │ │ │ ├── Order.java │ │ │ ├── Pet.java │ │ │ ├── Tag.java │ │ │ └── User.java │ │ └── repository/ │ │ ├── HashMapRepository.java │ │ ├── OrderRepository.java │ │ ├── PetRepository.java │ │ └── UserRepository.java │ └── resources/ │ ├── application.yml │ └── petstore.yml ├── demo-spring-boot-webflux-scalar/ │ ├── pom.xml │ ├── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── springdoc/ │ │ │ └── demo/ │ │ │ └── app3/ │ │ │ ├── WebfluxDemoApplication.java │ │ │ ├── controller/ │ │ │ │ ├── ExceptionTranslator.java │ │ │ │ ├── TweetController.java │ │ │ │ └── TweetMapper.java │ │ │ ├── dto/ │ │ │ │ └── TweetDTO.java │ │ │ ├── exception/ │ │ │ │ └── TweetNotFoundException.java │ │ │ ├── model/ │ │ │ │ └── Tweet.java │ │ │ ├── payload/ │ │ │ │ └── ErrorResponse.java │ │ │ └── repository/ │ │ │ └── TweetRepository.java │ │ └── resources/ │ │ └── application.yml │ └── target/ │ └── maven-status/ │ └── maven-compiler-plugin/ │ └── compile/ │ └── default-compile/ │ ├── createdFiles.lst │ └── inputFiles.lst ├── demo-spring-boot-webmvc-scalar/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── org/ │ │ └── springdoc/ │ │ └── demo/ │ │ └── services/ │ │ └── book/ │ │ ├── SpringdocApplication.java │ │ ├── controller/ │ │ │ └── BookController.java │ │ ├── exception/ │ │ │ ├── BookNotFoundException.java │ │ │ └── GlobalControllerExceptionHandler.java │ │ ├── model/ │ │ │ └── Book.java │ │ └── repository/ │ │ └── BookRepository.java │ └── resources/ │ ├── application.yml │ └── logback.xml ├── demo-spring-cloud-function/ │ ├── .gitignore │ ├── pom.xml │ ├── spring-cloud-function-webflux/ │ │ ├── .gitignore │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── springdoc/ │ │ │ └── demo/ │ │ │ └── services/ │ │ │ └── functions/ │ │ │ ├── PersonDTO.java │ │ │ └── SampleApplication.java │ │ └── resources/ │ │ └── application.yml │ └── spring-cloud-function-webmvc/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── org/ │ │ └── springdoc/ │ │ └── demo/ │ │ └── services/ │ │ └── functions/ │ │ ├── PersonDTO.java │ │ └── SampleApplication.java │ └── resources/ │ └── application.yml ├── demo-spring-data-rest/ │ ├── .gitignore │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── org/ │ │ └── springdoc/ │ │ └── demo/ │ │ └── data/ │ │ └── rest/ │ │ ├── Account.java │ │ ├── AccountRepository.java │ │ ├── Customer.java │ │ ├── CustomerRepository.java │ │ └── SpringdocApplication.java │ └── resources/ │ └── application.properties ├── demo-spring-hateoas/ │ ├── .gitignore │ ├── README.md │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── org/ │ │ └── springdoc/ │ │ └── demo/ │ │ └── services/ │ │ └── hateoas/ │ │ ├── DatabaseLoader.java │ │ ├── Employee.java │ │ ├── EmployeeController.java │ │ ├── EmployeeRepository.java │ │ └── SpringdocApplication.java │ └── resources/ │ └── application.properties ├── pom.xml └── settings.xml
SYMBOL INDEX (879 symbols across 142 files)
FILE: demo-book-service/src/main/java/org/springdoc/demo/services/book/SpringdocApplication.java
class SpringdocApplication (line 24) | @SpringBootApplication
method main (line 27) | public static void main(String[] args) {
FILE: demo-book-service/src/main/java/org/springdoc/demo/services/book/controller/BookController.java
class BookController (line 45) | @RestController
method BookController (line 59) | public BookController(BookRepository repository) {
method findById (line 69) | @GetMapping("/{id}")
method findBooks (line 80) | @GetMapping("/")
method updateBook (line 92) | @PutMapping("/{id}")
method patchBook (line 105) | @PatchMapping("/{id}")
method postBook (line 117) | @PostMapping("/")
method headBook (line 128) | @RequestMapping(method = RequestMethod.HEAD, value = "/")
method deleteBook (line 140) | @DeleteMapping("/{id}")
FILE: demo-book-service/src/main/java/org/springdoc/demo/services/book/exception/BookNotFoundException.java
class BookNotFoundException (line 21) | @SuppressWarnings("serial")
method BookNotFoundException (line 24) | public BookNotFoundException() {
FILE: demo-book-service/src/main/java/org/springdoc/demo/services/book/exception/GlobalControllerExceptionHandler.java
class GlobalControllerExceptionHandler (line 31) | @RestControllerAdvice
method handleConnversion (line 34) | @ExceptionHandler(ConversionFailedException.class)
method handleBookNotFound (line 44) | @ExceptionHandler(BookNotFoundException.class)
FILE: demo-book-service/src/main/java/org/springdoc/demo/services/book/model/Book.java
class Book (line 27) | public class Book {
method getId (line 53) | public long getId() {
method setId (line 62) | public void setId(long id) {
method getTitle (line 71) | public String getTitle() {
method setTitle (line 80) | public void setTitle(String title) {
method getAuthor (line 89) | public String getAuthor() {
method setAuthor (line 98) | public void setAuthor(String author) {
FILE: demo-book-service/src/main/java/org/springdoc/demo/services/book/repository/BookRepository.java
class BookRepository (line 30) | @Repository
method findById (line 35) | public Optional<Book> findById(long id) {
method add (line 39) | public void add(Book book) {
method getBooks (line 43) | public Collection<Book> getBooks() {
FILE: demo-book-service/src/test/java/org/springdoc/demo/services/book/SwaggerUnitTest.java
class SwaggerUnitTest (line 34) | @AutoConfigureMockMvc
method shouldDisplaySwaggerUiPage (line 41) | @Test
FILE: demo-microservices/config-service/src/main/java/org/springdoc/demo/services/config/ConfigApplication.java
class ConfigApplication (line 7) | @SpringBootApplication
method main (line 11) | public static void main(String[] args) {
FILE: demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/DepartmentApplication.java
class DepartmentApplication (line 14) | @SpringBootApplication
method main (line 22) | public static void main(String[] args) {
method repository (line 26) | @Bean
FILE: demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/client/EmployeeClient.java
type EmployeeClient (line 11) | @FeignClient(name = "employee-service")
method findByDepartment (line 14) | @GetMapping("/department/{departmentId}")
FILE: demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/controller/DepartmentController.java
class DepartmentController (line 17) | @RestController
method DepartmentController (line 26) | public DepartmentController(DepartmentRepository repository, EmployeeC...
method add (line 31) | @PostMapping("/")
method findById (line 37) | @GetMapping("/{id}")
method findAll (line 43) | @GetMapping("/")
method findByOrganization (line 49) | @GetMapping("/organization/{organizationId}")
method findByOrganizationWithEmployees (line 55) | @GetMapping("/organization/{organizationId}/with-employees")
FILE: demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/model/Department.java
class Department (line 6) | public class Department {
method Department (line 16) | public Department() {
method Department (line 20) | public Department(Long organizationId, String name) {
method getId (line 26) | public Long getId() {
method setId (line 30) | public void setId(Long id) {
method getOrganizationId (line 34) | public Long getOrganizationId() {
method setOrganizationId (line 38) | public void setOrganizationId(Long organizationId) {
method getName (line 42) | public String getName() {
method setName (line 46) | public void setName(String name) {
method getEmployees (line 50) | public List<Employee> getEmployees() {
method setEmployees (line 54) | public void setEmployees(List<Employee> employees) {
method toString (line 58) | @Override
FILE: demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/model/Employee.java
class Employee (line 3) | public class Employee {
method Employee (line 13) | public Employee() {
method Employee (line 17) | public Employee(String name, int age, String position) {
method getId (line 23) | public Long getId() {
method setId (line 27) | public void setId(Long id) {
method getName (line 31) | public String getName() {
method setName (line 35) | public void setName(String name) {
method getAge (line 39) | public int getAge() {
method setAge (line 43) | public void setAge(int age) {
method getPosition (line 47) | public String getPosition() {
method setPosition (line 51) | public void setPosition(String position) {
method toString (line 55) | @Override
FILE: demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/repository/DepartmentRepository.java
class DepartmentRepository (line 10) | public class DepartmentRepository {
method add (line 14) | public Department add(Department department) {
method findById (line 20) | public Department findById(Long id) {
method findAll (line 28) | public List<Department> findAll() {
method findByOrganization (line 32) | public List<Department> findByOrganization(Long organizationId) {
FILE: demo-microservices/discovery-service/src/main/java/org/springdoc/demo/services/discovery/DiscoveryApplication.java
class DiscoveryApplication (line 7) | @SpringBootApplication
method main (line 11) | public static void main(String[] args) {
FILE: demo-microservices/employee-service/src/main/java/org/springdoc/demo/services/employee/EmployeeApplication.java
class EmployeeApplication (line 13) | @SpringBootApplication
method main (line 20) | public static void main(String[] args) {
method repository (line 24) | @Bean
FILE: demo-microservices/employee-service/src/main/java/org/springdoc/demo/services/employee/controller/EmployeeController.java
class EmployeeController (line 16) | @RestController
method EmployeeController (line 23) | public EmployeeController(EmployeeRepository repository) {
method add (line 27) | @PostMapping("/")
method findById (line 33) | @GetMapping("/{id}")
method findAll (line 39) | @GetMapping("/")
method findByDepartment (line 45) | @GetMapping("/department/{departmentId}")
method findByOrganization (line 51) | @GetMapping("/organization/{organizationId}")
FILE: demo-microservices/employee-service/src/main/java/org/springdoc/demo/services/employee/model/Employee.java
class Employee (line 3) | public class Employee {
method Employee (line 17) | public Employee() {
method Employee (line 21) | public Employee(Long organizationId, Long departmentId, String name, i...
method getId (line 29) | public Long getId() {
method setId (line 33) | public void setId(Long id) {
method getOrganizationId (line 37) | public Long getOrganizationId() {
method setOrganizationId (line 41) | public void setOrganizationId(Long organizationId) {
method getDepartmentId (line 45) | public Long getDepartmentId() {
method setDepartmentId (line 49) | public void setDepartmentId(Long departmentId) {
method getName (line 53) | public String getName() {
method setName (line 57) | public void setName(String name) {
method getAge (line 61) | public int getAge() {
method setAge (line 65) | public void setAge(int age) {
method getPosition (line 69) | public String getPosition() {
method setPosition (line 73) | public void setPosition(String position) {
method toString (line 77) | @Override
FILE: demo-microservices/employee-service/src/main/java/org/springdoc/demo/services/employee/repository/EmployeeRepository.java
class EmployeeRepository (line 10) | public class EmployeeRepository {
method add (line 14) | public Employee add(Employee employee) {
method findById (line 20) | public Employee findById(Long id) {
method findAll (line 28) | public List<Employee> findAll() {
method findByDepartment (line 32) | public List<Employee> findByDepartment(Long departmentId) {
method findByOrganization (line 36) | public List<Employee> findByOrganization(Long organizationId) {
FILE: demo-microservices/gateway-service/src/main/java/org/springdoc/demo/services/gateway/ContextPathRewritePathGatewayFilterFactory.java
class ContextPathRewritePathGatewayFilterFactory (line 14) | @Component
method apply (line 17) | @Override
FILE: demo-microservices/gateway-service/src/main/java/org/springdoc/demo/services/gateway/GatewayApplication.java
class GatewayApplication (line 20) | @SpringBootApplication
method main (line 24) | public static void main(String[] args) {
method apis (line 28) | @Bean
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/OrganizationApplication.java
class OrganizationApplication (line 14) | @SpringBootApplication
method main (line 22) | public static void main(String[] args) {
method repository (line 26) | @Bean
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/client/DepartmentClient.java
type DepartmentClient (line 11) | @FeignClient(name = "department-service")
method findByOrganization (line 14) | @GetMapping("/organization/{organizationId}")
method findByOrganizationWithEmployees (line 17) | @GetMapping("/organization/{organizationId}/with-employees")
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/client/EmployeeClient.java
type EmployeeClient (line 11) | @FeignClient(name = "employee-service")
method findByOrganization (line 14) | @GetMapping("/organization/{organizationId}")
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/controller/OrganizationController.java
class OrganizationController (line 18) | @RestController
method OrganizationController (line 29) | public OrganizationController(OrganizationRepository repository, Depar...
method add (line 35) | @PostMapping
method findAll (line 41) | @GetMapping
method findById (line 47) | @GetMapping("/{id}")
method findByIdWithDepartments (line 53) | @GetMapping("/{id}/with-departments")
method findByIdWithDepartmentsAndEmployees (line 61) | @GetMapping("/{id}/with-departments-and-employees")
method findByIdWithEmployees (line 69) | @GetMapping("/{id}/with-employees")
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/model/Department.java
class Department (line 6) | public class Department {
method Department (line 14) | public Department() {
method Department (line 18) | public Department(String name) {
method getId (line 23) | public Long getId() {
method setId (line 27) | public void setId(Long id) {
method getName (line 31) | public String getName() {
method setName (line 35) | public void setName(String name) {
method getEmployees (line 39) | public List<Employee> getEmployees() {
method setEmployees (line 43) | public void setEmployees(List<Employee> employees) {
method toString (line 47) | @Override
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/model/Employee.java
class Employee (line 3) | public class Employee {
method Employee (line 13) | public Employee() {
method Employee (line 17) | public Employee(String name, int age, String position) {
method getId (line 23) | public Long getId() {
method setId (line 27) | public void setId(Long id) {
method getName (line 31) | public String getName() {
method setName (line 35) | public void setName(String name) {
method getAge (line 39) | public int getAge() {
method setAge (line 43) | public void setAge(int age) {
method getPosition (line 47) | public String getPosition() {
method setPosition (line 51) | public void setPosition(String position) {
method toString (line 55) | @Override
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/model/Organization.java
class Organization (line 6) | public class Organization {
method Organization (line 18) | public Organization() {
method Organization (line 22) | public Organization(String name, String address) {
method getId (line 27) | public Long getId() {
method setId (line 31) | public void setId(Long id) {
method getName (line 35) | public String getName() {
method setName (line 39) | public void setName(String name) {
method getAddress (line 43) | public String getAddress() {
method setAddress (line 47) | public void setAddress(String address) {
method getDepartments (line 51) | public List<Department> getDepartments() {
method setDepartments (line 55) | public void setDepartments(List<Department> departments) {
method getEmployees (line 59) | public List<Employee> getEmployees() {
method setEmployees (line 63) | public void setEmployees(List<Employee> employees) {
method toString (line 67) | @Override
FILE: demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/repository/OrganizationRepository.java
class OrganizationRepository (line 9) | public class OrganizationRepository {
method add (line 13) | public Organization add(Organization organization) {
method findById (line 19) | public Organization findById(Long id) {
method findAll (line 27) | public List<Organization> findAll() {
FILE: demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/AuthorizationServerApp.java
class AuthorizationServerApp (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) {
FILE: demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/DefaultSecurityConfig.java
class DefaultSecurityConfig (line 15) | @EnableWebSecurity
method defaultSecurityFilterChain (line 19) | @Bean
method users (line 31) | @Bean
FILE: demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/Jwks.java
class Jwks (line 10) | public final class Jwks {
method Jwks (line 12) | private Jwks() {
method generateRsa (line 15) | public static RSAKey generateRsa() {
FILE: demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/KeyGeneratorUtils.java
class KeyGeneratorUtils (line 11) | final class KeyGeneratorUtils {
method KeyGeneratorUtils (line 13) | private KeyGeneratorUtils() {
method generateRsaKey (line 16) | static KeyPair generateRsaKey() {
method generateEcKey (line 29) | static KeyPair generateEcKey() {
FILE: demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/SecurityConfig.java
class SecurityConfig (line 45) | @Configuration(proxyBeanMethods = false)
method corsConfigurationSource (line 51) | @Bean
method authorizationServerSecurityFilterChain (line 62) | @Bean
method registeredClientRepository (line 78) | @Bean
method authorizationService (line 106) | @Bean
method authorizationConsentService (line 111) | @Bean
method jwkSource (line 116) | @Bean
method jwtDecoder (line 123) | @Bean
method authorizationServerSettings (line 128) | @Bean
method embeddedDatabase (line 133) | @Bean
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/ResourceServerApp.java
class ResourceServerApp (line 13) | @SpringBootApplication
method main (line 16) | public static void main(String[] args) throws Exception {
method customOpenAPI (line 20) | @Bean
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/config/OpenApiConfig.java
class OpenApiConfig (line 29) | @OpenAPIDefinition(info = @Info(title = "My App",
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/config/SecurityConfig.java
class SecurityConfig (line 9) | @Configuration
method configure (line 12) | @Bean
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/model/Foo.java
class Foo (line 8) | @Entity
method Foo (line 17) | protected Foo() {
method Foo (line 20) | public Foo(String name) {
method getId (line 24) | public Long getId() {
method setId (line 28) | public void setId(Long id) {
method getName (line 32) | public String getName() {
method setName (line 36) | public void setName(String name) {
method hashCode (line 40) | @Override
method equals (line 50) | @Override
method toString (line 74) | @Override
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/repository/IFooRepository.java
type IFooRepository (line 8) | public interface IFooRepository extends PagingAndSortingRepository<Foo, ...
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/service/IFooService.java
type IFooService (line 8) | public interface IFooService {
method findById (line 9) | Optional<Foo> findById(Long id);
method save (line 11) | Foo save(Foo foo);
method findAll (line 13) | Iterable<Foo> findAll();
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/service/impl/FooServiceImpl.java
class FooServiceImpl (line 11) | @Service
method FooServiceImpl (line 16) | public FooServiceImpl(IFooRepository fooRepository) {
method findById (line 20) | @Override
method save (line 25) | @Override
method findAll (line 30) | @Override
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/web/controller/FooController.java
class FooController (line 24) | @RestController
method FooController (line 31) | public FooController(IFooService fooService) {
method findOne (line 35) | @GetMapping(value = "/{id}")
method create (line 42) | @ResponseStatus(HttpStatus.CREATED)
method findAll (line 49) | @GetMapping
method updateFoo (line 57) | @PutMapping("/{id}")
method convertToDto (line 63) | protected FooDTO convertToDto(Foo entity) {
method convertToEntity (line 69) | protected Foo convertToEntity(FooDTO dto) {
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/web/controller/UserInfoController.java
class UserInfoController (line 13) | @RestController
method getUserInfo (line 16) | @GetMapping("/user/info")
FILE: demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/web/dto/FooDTO.java
class FooDTO (line 3) | public class FooDTO {
method FooDTO (line 8) | public FooDTO() {
method FooDTO (line 12) | public FooDTO(final long id, final String name) {
method getId (line 21) | public long getId() {
method setId (line 25) | public void setId(final long id) {
method getName (line 29) | public String getName() {
method setName (line 33) | public void setName(final String name) {
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/ResourceServerApp.java
class ResourceServerApp (line 6) | @SpringBootApplication
method main (line 9) | public static void main(String[] args) throws Exception {
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/config/OpenApiConfig.java
class OpenApiConfig (line 29) | @OpenAPIDefinition(info = @Info(title = "Foo API",
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/config/SecurityConfig.java
class SecurityConfig (line 10) | @Configuration
method filterChain1 (line 13) | @Bean
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/model/Foo.java
class Foo (line 10) | @Entity
method Foo (line 19) | protected Foo() {
method Foo (line 22) | public Foo(String name) {
method getId (line 26) | public UUID getId() {
method setId (line 30) | public void setId(UUID id) {
method getName (line 34) | public String getName() {
method setName (line 38) | public void setName(String name) {
method hashCode (line 42) | @Override
method equals (line 52) | @Override
method toString (line 76) | @Override
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/repository/IFooRepository.java
type IFooRepository (line 8) | public interface IFooRepository extends PagingAndSortingRepository<Foo, ...
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/service/IFooService.java
type IFooService (line 8) | public interface IFooService {
method findById (line 9) | Optional<Foo> findById(Long id);
method save (line 11) | Foo save(Foo foo);
method findAll (line 13) | Iterable<Foo> findAll();
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/service/impl/FooServiceImpl.java
class FooServiceImpl (line 11) | @Service
method FooServiceImpl (line 16) | public FooServiceImpl(IFooRepository fooRepository) {
method findById (line 20) | @Override
method save (line 25) | @Override
method findAll (line 30) | @Override
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/web/controller/FooController.java
class FooController (line 24) | @RestController
method FooController (line 31) | public FooController(IFooService fooService) {
method findOne (line 35) | @GetMapping(value = "/{id}")
method create (line 42) | @ResponseStatus(HttpStatus.CREATED)
method findAll (line 49) | @GetMapping
method updateFoo (line 57) | @PutMapping("/{id}")
method convertToDto (line 63) | protected FooDTO convertToDto(Foo entity) {
method convertToEntity (line 69) | protected Foo convertToEntity(FooDTO dto) {
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/web/controller/UserInfoController.java
class UserInfoController (line 13) | @RestController
method getUserInfo (line 16) | @GetMapping("/user/info")
FILE: demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/web/dto/FooDTO.java
class FooDTO (line 5) | public class FooDTO {
method FooDTO (line 10) | public FooDTO() {
method FooDTO (line 14) | public FooDTO(final UUID id, final String name) {
method getId (line 21) | public UUID getId() {
method setId (line 25) | public void setId(UUID id) {
method getName (line 29) | public String getName() {
method setName (line 33) | public void setName(final String name) {
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/SampleApplication.java
class SampleApplication (line 14) | @SpringBootApplication()
method main (line 17) | public static void main(String[] args) {
method customOpenAPI (line 21) | @Bean
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/config/SampleConfig.java
class SampleConfig (line 14) | @Configuration
method initConfig (line 17) | @PostConstruct
method moneyModule (line 23) | @Bean
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/controller/PersonController.java
class PersonController (line 18) | @RestController
method person (line 23) | @PostMapping("/persons")
method findByLastName (line 32) | @GetMapping(path = "/persons")
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/exceptions/ErrorMessage.java
class ErrorMessage (line 8) | public class ErrorMessage {
method ErrorMessage (line 12) | public ErrorMessage() {
method ErrorMessage (line 15) | public ErrorMessage(List<String> errors) {
method ErrorMessage (line 19) | public ErrorMessage(String error) {
method ErrorMessage (line 23) | public ErrorMessage(String... errors) {
method getErrors (line 27) | public List<String> getErrors() {
method setErrors (line 31) | public void setErrors(List<String> errors) {
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/exceptions/GlobalControllerAdvice.java
class GlobalControllerAdvice (line 28) | @ControllerAdvice(assignableTypes = PersonController.class)
method problem (line 36) | @ExceptionHandler(Throwable.class)
method handleMethodArgumentNotValid (line 50) | @ExceptionHandler(MethodArgumentNotValidException.class)
method handleConstraintViolatedException (line 72) | @ExceptionHandler(ConstraintViolationException.class)
method handleMissingServletRequestParameterException (line 91) | @ExceptionHandler(MissingServletRequestParameterException.class)
method handleHttpMediaTypeNotSupported (line 104) | @ExceptionHandler(HttpMediaTypeNotSupportedException.class)
method handleHttpMessageNotReadable (line 114) | @ExceptionHandler(HttpMessageNotReadableException.class)
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/exceptions/Problem.java
class Problem (line 3) | public class Problem {
method Problem (line 9) | public Problem(String logRef, String message) {
method Problem (line 15) | public Problem() {
method getLogRef (line 20) | public String getLogRef() {
method setLogRef (line 24) | public void setLogRef(String logRef) {
method getMessage (line 28) | public String getMessage() {
method setMessage (line 32) | public void setMessage(String message) {
FILE: demo-person-service/src/main/java/org/springdoc/demo/services/person/model/Person.java
class Person (line 13) | public class Person {
method getWorth (line 38) | public MonetaryAmount getWorth() {
method setWorth (line 42) | public void setWorth(MonetaryAmount worth) {
method getId (line 46) | public long getId() {
method setId (line 50) | public void setId(long id) {
method getEmail1 (line 54) | public String getEmail1() {
method setEmail1 (line 58) | public void setEmail1(String email1) {
method getEmail2 (line 62) | public String getEmail2() {
method setEmail2 (line 66) | public void setEmail2(String email2) {
method getFirstName (line 70) | public String getFirstName() {
method setFirstName (line 74) | public void setFirstName(String firstName) {
method getLastName (line 78) | public String getLastName() {
method setLastName (line 82) | public void setLastName(String lastName) {
method getAge (line 86) | public int getAge() {
method setAge (line 90) | public void setAge(int age) {
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/AppNativeConfiguration.java
class AppNativeConfiguration (line 18) | @Configuration
class AppNativeRuntimeHints (line 30) | static class AppNativeRuntimeHints implements RuntimeHintsRegistrar {
method registerHints (line 32) | @Override
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/WebfluxFunctionalDemoApplication.java
class WebfluxFunctionalDemoApplication (line 29) | @SpringBootApplication
method main (line 32) | public static void main(String[] args) {
method employeesOpenApi (line 36) | @Bean
method userOpenApi (line 45) | @Bean
method coffeeOpenApi (line 54) | @Bean
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/Coffee.java
class Coffee (line 7) | public class Coffee {
method Coffee (line 13) | public Coffee() {
method Coffee (line 16) | public Coffee(String name) {
method Coffee (line 20) | public Coffee(String id, String name) {
method getId (line 25) | public String getId() {
method setId (line 29) | public void setId(String id) {
method getName (line 33) | public String getName() {
method setName (line 37) | public void setName(String name) {
method equals (line 41) | @Override
method hashCode (line 50) | @Override
method toString (line 55) | @Override
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/CoffeeOrder.java
class CoffeeOrder (line 6) | public class CoffeeOrder {
method CoffeeOrder (line 11) | public CoffeeOrder() {
method CoffeeOrder (line 14) | public CoffeeOrder(String coffeeId, Instant whenOrdered) {
method getCoffeeId (line 19) | public String getCoffeeId() {
method getWhenOrdered (line 23) | public Instant getWhenOrdered() {
method equals (line 27) | @Override
method hashCode (line 36) | @Override
method toString (line 41) | @Override
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/CoffeeRepository.java
type CoffeeRepository (line 5) | public interface CoffeeRepository extends ReactiveCrudRepository<Coffee,...
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/CoffeeService.java
class CoffeeService (line 13) | @Service
method CoffeeService (line 17) | public CoffeeService(CoffeeRepository repo) {
method getAllCoffees (line 21) | Flux<Coffee> getAllCoffees() {
method getCoffeeById (line 25) | Mono<Coffee> getCoffeeById(@Parameter(in = ParameterIn.PATH) String id) {
method getOrdersForCoffeeById (line 29) | Flux<CoffeeOrder> getOrdersForCoffeeById(@Parameter(in = ParameterIn.P...
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/RouteConfig.java
class RouteConfig (line 14) | @Configuration
method RouteConfig (line 18) | public RouteConfig(CoffeeService service) {
method routerFunction (line 22) | @Bean
method all (line 29) | private Mono<ServerResponse> all(ServerRequest req) {
method byId (line 34) | private Mono<ServerResponse> byId(ServerRequest req) {
method orders (line 39) | private Mono<ServerResponse> orders(ServerRequest req) {
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/employee/Employee.java
class Employee (line 7) | @Data
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/employee/EmployeeFunctionalConfig.java
class EmployeeFunctionalConfig (line 23) | @Configuration
method employeeRepository (line 27) | @Bean
method getAllEmployeesRoute (line 32) | @Bean
method getEmployeeByIdRoute (line 40) | @Bean
method updateEmployeeRoute (line 46) | @Bean
method composedRoutes (line 52) | RouterFunction<ServerResponse> composedRoutes() {
method findAllEmployeesFunction (line 58) | private HandlerFunction<ServerResponse> findAllEmployeesFunction() {
method updateEmployeeFunction (line 63) | private HandlerFunction<ServerResponse> updateEmployeeFunction() {
method findEmployeeByIdFunction (line 69) | private HandlerFunction<ServerResponse> findEmployeeByIdFunction() {
method getOpenAPI (line 74) | private Consumer<Builder> getOpenAPI(String findAllEmployees) {
method findEmployeeByIdOpenAPI (line 78) | private Consumer<Builder> findEmployeeByIdOpenAPI() {
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/employee/EmployeeRepository.java
class EmployeeRepository (line 12) | @Tag(name = "Employees")
method findEmployeeById (line 45) | public Mono<Employee> findEmployeeById(@Parameter(in = ParameterIn.PAT...
method findAllEmployees (line 49) | public Flux<Employee> findAllEmployees() {
method updateEmployee (line 53) | public Mono<Employee> updateEmployee(Employee employee) {
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/user/RoutingConfiguration.java
class RoutingConfiguration (line 13) | @Configuration
method monoRouterFunction (line 16) | @Bean
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/user/User.java
class User (line 3) | public class User {
method User (line 12) | public User() {
method User (line 15) | public User(long id, String firstname, String lastname, int age) {
method getId (line 22) | public long getId() {
method setId (line 26) | public void setId(Long id) {
method getFirstname (line 30) | public String getFirstname() {
method setFirstname (line 34) | public void setFirstname(String firstname) {
method getLastname (line 38) | public String getLastname() {
method setLastname (line 42) | public void setLastname(String lastname) {
method getAge (line 46) | public int getAge() {
method setAge (line 50) | public void setAge(int age) {
method toString (line 54) | @Override
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/user/UserHandler.java
class UserHandler (line 13) | @Component
method UserHandler (line 18) | public UserHandler(UserRepository repository) {
method getAll (line 25) | public Mono<ServerResponse> getAll(ServerRequest request) {
method getUser (line 36) | public Mono<ServerResponse> getUser(ServerRequest request) {
method postUser (line 55) | public Mono<ServerResponse> postUser(ServerRequest request) {
method putUser (line 63) | public Mono<ServerResponse> putUser(ServerRequest request) {
method deleteUser (line 81) | public Mono<ServerResponse> deleteUser(ServerRequest request) {
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/user/UserRepository.java
type UserRepository (line 10) | @Tag(name = "Users")
method getUserById (line 13) | public Mono<User> getUserById(@Parameter(in = ParameterIn.PATH, descri...
method getAllUsers (line 15) | @Operation(description = "get all the users")
method getAllUsers (line 18) | @Operation(description = "get all the users by firstname")
method saveUser (line 21) | public Mono<Void> saveUser(Mono<User> user);
method putUser (line 23) | public Mono<User> putUser(@Parameter(in = ParameterIn.PATH) Long id, M...
method deleteUser (line 25) | public Mono<String> deleteUser(@Parameter(in = ParameterIn.PATH) Long ...
FILE: demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/user/UserRepositoryImpl.java
class UserRepositoryImpl (line 13) | @Repository
method init (line 17) | @PostConstruct
method getUserById (line 23) | @Override
method getAllUsers (line 28) | @Override
method getAllUsers (line 33) | @Override
method saveUser (line 38) | @Override
method putUser (line 51) | @Override
method deleteUser (line 67) | @Override
FILE: demo-spring-boot-3-webflux-functional/src/main/resources/schema.sql
type COFFEE (line 1) | CREATE TABLE COFFEE
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/WebfluxDemoApplication.java
class WebfluxDemoApplication (line 34) | @SpringBootApplication
method main (line 38) | public static void main(String[] args) {
method customOpenAPI (line 42) | @Bean
method storeOpenApi (line 52) | @Bean
method userOpenApi (line 59) | @Bean
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/controller/ExceptionTranslator.java
class ExceptionTranslator (line 31) | @RestControllerAdvice
method handleDuplicateKeyException (line 35) | @SuppressWarnings("rawtypes")
method handleTweetNotFoundException (line 43) | @SuppressWarnings("rawtypes")
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/controller/TweetController.java
class TweetController (line 45) | @RestController
method TweetController (line 52) | public TweetController(TweetRepository tweetRepository, TweetMapper tw...
method getAllTweets (line 57) | @ApiResponses(value = { @ApiResponse(responseCode = "200", description...
method createTweets (line 64) | @PostMapping("/tweets")
method getTweetById (line 70) | @ApiResponses(value = { @ApiResponse(responseCode = "200", description...
method updateTweet (line 78) | @ApiResponses(value = { @ApiResponse(responseCode = "200", description...
method deleteTweet (line 90) | @ApiResponses(value = { @ApiResponse(responseCode = "200", description...
method streamAllTweets (line 100) | @Operation(description = "Tweets are Sent to the client as Server Sent...
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/controller/TweetMapper.java
class TweetMapper (line 29) | @Component
method toDTO (line 32) | Flux<TweetDTO> toDTO(Flux<Tweet> tweet) {
method toEntity (line 36) | Flux<Tweet> toEntity(Flux<TweetDTO> tweetDTO) {
method toDTO (line 40) | Mono<TweetDTO> toDTO(Mono<Tweet> tweet) {
method toEntity (line 44) | Mono<Tweet> toEntity(Mono<TweetDTO> tweetDTO) {
method toDTO (line 48) | TweetDTO toDTO(Tweet tweet) {
method toEntity (line 54) | Tweet toEntity(TweetDTO tweetDTO) {
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/dto/TweetDTO.java
class TweetDTO (line 31) | public class TweetDTO {
method TweetDTO (line 41) | public TweetDTO() {
method TweetDTO (line 45) | public TweetDTO(String text) {
method getId (line 49) | public String getId() {
method setId (line 53) | public void setId(String id) {
method getText (line 57) | public String getText() {
method setText (line 61) | public void setText(String text) {
method getCreatedAt (line 65) | public Date getCreatedAt() {
method setCreatedAt (line 69) | public void setCreatedAt(Date createdAt) {
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/exception/TweetNotFoundException.java
class TweetNotFoundException (line 24) | public class TweetNotFoundException extends RuntimeException {
method TweetNotFoundException (line 31) | public TweetNotFoundException(String tweetId) {
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/model/Tweet.java
class Tweet (line 34) | @Document(collection = "tweets")
method Tweet (line 46) | public Tweet() {
method Tweet (line 50) | public Tweet(String text) {
method getId (line 54) | public String getId() {
method setId (line 58) | public void setId(String id) {
method getText (line 62) | public String getText() {
method setText (line 66) | public void setText(String text) {
method getCreatedAt (line 70) | public Date getCreatedAt() {
method setCreatedAt (line 74) | public void setCreatedAt(Date createdAt) {
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/payload/ErrorResponse.java
class ErrorResponse (line 24) | public class ErrorResponse {
method ErrorResponse (line 27) | public ErrorResponse(String message) {
method getMessage (line 31) | public String getMessage() {
method setMessage (line 35) | public void setMessage(String message) {
FILE: demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/repository/TweetRepository.java
type TweetRepository (line 29) | @Repository
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/Application.java
class Application (line 37) | @SpringBootApplication
method main (line 40) | public static void main(String[] args) {
method actuatorApi (line 44) | @Bean
method usersGroup (line 60) | @Bean
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/ApiUtil.java
class ApiUtil (line 29) | public class ApiUtil {
method setExampleResponse (line 31) | public static void setExampleResponse(NativeWebRequest req, String con...
method checkApiKey (line 41) | public static void checkApiKey(NativeWebRequest req) {
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/ExceptionTranslator.java
class ExceptionTranslator (line 34) | @RestControllerAdvice
method ExceptionTranslator (line 39) | public ExceptionTranslator(ErrorAttributes errorAttributes) {
method processConstraintViolationException (line 43) | @ExceptionHandler(ConstraintViolationException.class)
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/PetApi.java
type PetApi (line 64) | @SecurityScheme(name = "petstore_auth", type = SecuritySchemeType.OAUTH2...
method getDelegate (line 70) | default PetApiDelegate getDelegate() {
method addPet (line 75) | @Operation(summary = "Add a new pet to the store", description = "Add ...
method deletePet (line 87) | @Operation(summary = "Deletes a pet", description = "", security = {
method findPetsByStatus (line 97) | @Operation(summary = "Finds Pets by status", description = "Multiple s...
method findPetsByTags (line 107) | @Operation(summary = "Finds Pets by tags", description = "Multiple tag...
method getPetById (line 118) | @Operation(summary = "Find pet by ID", description = "Returns a single...
method updatePet (line 132) | @Operation(summary = "Update an existing pet", description = "Update a...
method updatePetWithForm (line 148) | @Operation(summary = "Updates a pet in the store with form data", desc...
method uploadFile (line 159) | @Operation(summary = "uploads an image", security = {
method getAllPets (line 172) | @Operation(summary = "Get all Pets paged", description = "Get all Pets...
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/PetApiController.java
class PetApiController (line 26) | @RestController
method PetApiController (line 32) | public PetApiController(@org.springframework.beans.factory.annotation....
method getDelegate (line 37) | @Override
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/PetApiDelegate.java
type PetApiDelegate (line 41) | public interface PetApiDelegate {
method getRequest (line 43) | default Optional<NativeWebRequest> getRequest() {
method addPet (line 50) | default void addPet(Pet pet) {
method deletePet (line 57) | default ResponseEntity<Void> deletePet(Long petId,
method findPetsByStatus (line 66) | default ResponseEntity<List<Pet>> findPetsByStatus(List<String> status) {
method extract (line 72) | default void extract() {
method findPetsByTags (line 90) | default ResponseEntity<List<Pet>> findPetsByTags(List<String> tags) {
method getPetById (line 99) | default ResponseEntity<Pet> getPetById(Long petId) {
method updatePet (line 108) | default ResponseEntity<Void> updatePet(Pet pet) {
method updatePetWithForm (line 116) | default ResponseEntity<Void> updatePetWithForm(Long petId,
method uploadFile (line 126) | default ResponseEntity<ModelApiResponse> uploadFile(Long petId,
method getAllPets (line 141) | default ResponseEntity<List<Pet>> getAllPets(@NotNull Pageable pageabl...
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/PetApiDelegateImpl.java
class PetApiDelegateImpl (line 47) | @Service
method PetApiDelegateImpl (line 54) | public PetApiDelegateImpl(PetRepository petRepository, NativeWebReques...
method createPet (line 59) | private static Pet createPet(long id, Category category, String name, ...
method initPets (line 74) | @PostConstruct
method addPet (line 106) | @Override
method deletePet (line 112) | @Override
method findPetsByStatus (line 118) | @Override
method findPetsByTags (line 127) | @Override
method getPetById (line 132) | @Override
method updatePet (line 139) | @Override
method updatePetWithForm (line 145) | @Override
method uploadFile (line 156) | @Override
method getAllPets (line 172) | public ResponseEntity<List<Pet>> getAllPets(@NotNull Pageable pageable) {
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/StoreApi.java
type StoreApi (line 48) | @Tag(name = "store", description = "the store API")
method getDelegate (line 51) | default StoreApiDelegate getDelegate() {
method deleteOrder (line 56) | @Operation(summary = "Delete purchase order by ID", description = "For...
method getInventory (line 65) | @Operation(summary = "Returns pet inventories by status", description ...
method getOrderById (line 74) | @Operation(summary = "Find purchase order by ID", description = "For v...
method placeOrder (line 86) | @Operation(summary = "Place an order for a pet", description = "Place ...
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/StoreApiController.java
class StoreApiController (line 26) | @RestController
method StoreApiController (line 32) | public StoreApiController(@org.springframework.beans.factory.annotatio...
method getDelegate (line 37) | @Override
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/StoreApiDelegate.java
type StoreApiDelegate (line 35) | public interface StoreApiDelegate {
method getRequest (line 37) | default Optional<NativeWebRequest> getRequest() {
method deleteOrder (line 44) | default ResponseEntity<Void> deleteOrder(Long orderId) {
method getInventory (line 52) | default ResponseEntity<Map<String, Integer>> getInventory() {
method getOrderById (line 60) | default ResponseEntity<Order> getOrderById(Long orderId) {
method extract (line 66) | default void extract() {
method placeOrder (line 84) | default ResponseEntity<Order> placeOrder(Order order) {
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/StoreApiDelegateImpl.java
class StoreApiDelegateImpl (line 35) | @Service
method StoreApiDelegateImpl (line 45) | public StoreApiDelegateImpl(OrderRepository orderRepository, PetReposi...
method createOrder (line 51) | private static Order createOrder(long id, long petId, Order.StatusEnum...
method initOrders (line 60) | @PostConstruct
method deleteOrder (line 74) | @Override
method getInventory (line 82) | @Override
method getOrderById (line 88) | @Override
method placeOrder (line 95) | @Override
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/UserApi.java
type UserApi (line 52) | @Tag(name = "user", description = "the user API")
method getDelegate (line 55) | default UserApiDelegate getDelegate() {
method createUser (line 60) | @Operation(summary = "Create user", description = "This can only be do...
method createUsersWithArrayInput (line 68) | @Operation(summary = "Creates list of users with given input array", t...
method createUsersWithListInput (line 77) | @Operation(summary = "Creates list of users with given input array", d...
method deleteUser (line 89) | @Operation(summary = "Delete user", description = "This can only be do...
method getUserByName (line 101) | @Operation(summary = "Get user by user name", tags = { "user" })
method loginUser (line 113) | @Operation(summary = "Logs user into the system", tags = { "user" })
method logoutUser (line 127) | @Operation(summary = "Logs out current logged in user session", tags =...
method updateUser (line 134) | @Operation(summary = "Update user", description = "This can only be do...
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/UserApiController.java
class UserApiController (line 26) | @RestController
method UserApiController (line 32) | public UserApiController(@org.springframework.beans.factory.annotation...
method getDelegate (line 37) | @Override
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/UserApiDelegate.java
type UserApiDelegate (line 36) | public interface UserApiDelegate {
method getRequest (line 38) | default Optional<NativeWebRequest> getRequest() {
method createUser (line 45) | default ResponseEntity<Void> createUser(User user) {
method createUsersWithArrayInput (line 53) | default ResponseEntity<Void> createUsersWithArrayInput(List<User> user) {
method createUsersWithListInput (line 61) | default ResponseEntity<Void> createUsersWithListInput(List<User> user) {
method deleteUser (line 69) | default ResponseEntity<Void> deleteUser(String username) {
method getUserByName (line 77) | default ResponseEntity<User> getUserByName(String username) {
method loginUser (line 97) | default ResponseEntity<String> loginUser(String username,
method logoutUser (line 106) | default ResponseEntity<Void> logoutUser() {
method updateUser (line 114) | default ResponseEntity<Void> updateUser(String username,
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/UserApiDelegateImpl.java
class UserApiDelegateImpl (line 35) | @Service
method UserApiDelegateImpl (line 40) | public UserApiDelegateImpl(UserRepository userRepository) {
method createUser (line 44) | private static User createUser(long id, String username, String firstN...
method initUsers (line 56) | @PostConstruct
method createUser (line 82) | @Override
method createUsersWithArrayInput (line 88) | @Override
method createUsersWithListInput (line 94) | @Override
method deleteUser (line 99) | @Override
method getUserByName (line 107) | @Override
method loginUser (line 114) | @Override
method logoutUser (line 123) | @Override
method updateUser (line 128) | @Override
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/Body.java
class Body (line 24) | public class Body {
method toIndentedString (line 42) | private static String toIndentedString(java.lang.Object o) {
method getName (line 54) | @JsonProperty("name")
method setName (line 59) | public void setName(String name) {
method name (line 63) | public Body name(String name) {
method getStatus (line 73) | @JsonProperty("status")
method setStatus (line 78) | public void setStatus(String status) {
method status (line 82) | public Body status(String status) {
method toString (line 87) | @Override
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/Body1.java
class Body1 (line 26) | public class Body1 {
method toIndentedString (line 44) | private static String toIndentedString(java.lang.Object o) {
method getAdditionalMetadata (line 56) | @JsonProperty("additionalMetadata")
method setAdditionalMetadata (line 61) | public void setAdditionalMetadata(String additionalMetadata) {
method additionalMetadata (line 65) | public Body1 additionalMetadata(String additionalMetadata) {
method getFile (line 75) | @JsonProperty("file")
method setFile (line 80) | public void setFile(File file) {
method file (line 84) | public Body1 file(File file) {
method toString (line 89) | @Override
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/Category.java
class Category (line 35) | @JacksonXmlRootElement(localName = "category")
method id (line 53) | public Category id(Long id) {
method getId (line 64) | @Schema(example = "1", description = "")
method setId (line 71) | public void setId(Long id) {
method name (line 76) | public Category name(String name) {
method getName (line 87) | @Schema(example = "Dogs", description = "")
method setName (line 94) | public void setName(String name) {
method equals (line 99) | @Override
method hashCode (line 112) | @Override
method toString (line 117) | @Override
method toIndentedString (line 132) | private String toIndentedString(Object o) {
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/ModelApiResponse.java
class ModelApiResponse (line 35) | @JacksonXmlRootElement(localName = "##default")
method code (line 59) | public ModelApiResponse code(Integer code) {
method getCode (line 70) | @Schema(description = "")
method setCode (line 77) | public void setCode(Integer code) {
method type (line 82) | public ModelApiResponse type(String type) {
method getType (line 93) | @Schema(description = "")
method setType (line 100) | public void setType(String type) {
method message (line 105) | public ModelApiResponse message(String message) {
method getMessage (line 116) | @Schema(description = "")
method setMessage (line 123) | public void setMessage(String message) {
method equals (line 128) | @Override
method hashCode (line 142) | @Override
method toString (line 147) | @Override
method toIndentedString (line 163) | private String toIndentedString(Object o) {
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/Order.java
class Order (line 39) | @JacksonXmlRootElement(localName = "order")
method id (line 78) | public Order id(Long id) {
method getId (line 88) | @Schema(example = "10", description = "")
method setId (line 95) | public void setId(Long id) {
method petId (line 99) | public Order petId(Long petId) {
method getPetId (line 109) | @Schema(example = "198772", description = "")
method setPetId (line 116) | public void setPetId(Long petId) {
method quantity (line 120) | public Order quantity(Integer quantity) {
method getQuantity (line 130) | @Schema(example = "7", description = "")
method setQuantity (line 137) | public void setQuantity(Integer quantity) {
method shipDate (line 141) | public Order shipDate(Date shipDate) {
method getShipDate (line 151) | @Schema(description = "")
method setShipDate (line 159) | public void setShipDate(Date shipDate) {
method status (line 163) | public Order status(StatusEnum status) {
method getStatus (line 173) | @Schema(example = "approved", description = "Order Status")
method setStatus (line 180) | public void setStatus(StatusEnum status) {
method complete (line 184) | public Order complete(Boolean complete) {
method getComplete (line 194) | @Schema(description = "")
method setComplete (line 201) | public void setComplete(Boolean complete) {
method equals (line 205) | @Override
method hashCode (line 222) | @Override
method toString (line 227) | @Override
method toIndentedString (line 246) | private String toIndentedString(Object o) {
type StatusEnum (line 256) | public enum StatusEnum {
method StatusEnum (line 265) | StatusEnum(String value) {
method fromValue (line 269) | @JsonCreator
method toString (line 279) | @Override
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/Pet.java
class Pet (line 42) | @JacksonXmlRootElement(localName = "pet")
method id (line 84) | public Pet id(Long id) {
method getId (line 94) | @Schema(example = "10", description = "")
method setId (line 101) | public void setId(Long id) {
method name (line 105) | public Pet name(String name) {
method getName (line 115) | @Schema(example = "doggie", required = true, description = "")
method setName (line 123) | public void setName(String name) {
method category (line 127) | public Pet category(Category category) {
method getCategory (line 137) | @Schema(description = "")
method setCategory (line 145) | public void setCategory(Category category) {
method photoUrls (line 149) | public Pet photoUrls(List<String> photoUrls) {
method addPhotoUrlsItem (line 154) | public Pet addPhotoUrlsItem(String photoUrlsItem) {
method getPhotoUrls (line 164) | @Schema(required = true, description = "")
method setPhotoUrls (line 172) | public void setPhotoUrls(List<String> photoUrls) {
method tags (line 176) | public Pet tags(List<Tag> tags) {
method addTagsItem (line 181) | public Pet addTagsItem(Tag tagsItem) {
method getTags (line 194) | @Schema(description = "")
method setTags (line 202) | public void setTags(List<Tag> tags) {
method status (line 206) | public Pet status(StatusEnum status) {
method getStatus (line 216) | @Schema(description = "pet status in the store")
method setStatus (line 223) | public void setStatus(StatusEnum status) {
method equals (line 227) | @Override
method hashCode (line 244) | @Override
method toString (line 249) | @Override
method toIndentedString (line 268) | private String toIndentedString(Object o) {
type StatusEnum (line 278) | public enum StatusEnum {
method StatusEnum (line 287) | StatusEnum(String value) {
method fromValue (line 291) | @JsonCreator
method toString (line 301) | @Override
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/Tag.java
class Tag (line 35) | @JacksonXmlRootElement(localName = "tag")
method id (line 53) | public Tag id(Long id) {
method getId (line 64) | @Schema(description = "")
method setId (line 71) | public void setId(Long id) {
method name (line 76) | public Tag name(String name) {
method getName (line 87) | @Schema(description = "")
method setName (line 94) | public void setName(String name) {
method equals (line 99) | @Override
method hashCode (line 112) | @Override
method toString (line 117) | @Override
method toIndentedString (line 132) | private String toIndentedString(Object o) {
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/User.java
class User (line 35) | @JacksonXmlRootElement(localName = "user")
method id (line 89) | public User id(Long id) {
method getId (line 100) | @Schema(example = "10", description = "")
method setId (line 107) | public void setId(Long id) {
method username (line 112) | public User username(String username) {
method getUsername (line 123) | @Schema(example = "theUser", description = "")
method setUsername (line 130) | public void setUsername(String username) {
method firstName (line 135) | public User firstName(String firstName) {
method getFirstName (line 146) | @Schema(example = "John", description = "")
method setFirstName (line 153) | public void setFirstName(String firstName) {
method lastName (line 158) | public User lastName(String lastName) {
method getLastName (line 169) | @Schema(example = "James", description = "")
method setLastName (line 176) | public void setLastName(String lastName) {
method email (line 181) | public User email(String email) {
method getEmail (line 192) | @Schema(example = "john@email.com", description = "")
method setEmail (line 199) | public void setEmail(String email) {
method password (line 204) | public User password(String password) {
method getPassword (line 215) | @Schema(example = "12345", description = "")
method setPassword (line 222) | public void setPassword(String password) {
method phone (line 227) | public User phone(String phone) {
method getPhone (line 238) | @Schema(example = "12345", description = "")
method setPhone (line 245) | public void setPhone(String phone) {
method userStatus (line 250) | public User userStatus(Integer userStatus) {
method getUserStatus (line 261) | @Schema(example = "1", description = "User Status")
method setUserStatus (line 268) | public void setUserStatus(Integer userStatus) {
method equals (line 273) | @Override
method hashCode (line 292) | @Override
method toString (line 297) | @Override
method toIndentedString (line 318) | private String toIndentedString(Object o) {
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/repository/HashMapRepository.java
class HashMapRepository (line 40) | @NoRepositoryBean
method HashMapRepository (line 47) | protected HashMapRepository(Class<T> clazz) {
method getEntityId (line 51) | abstract <S extends T> ID getEntityId(S entity);
method save (line 53) | @Override
method saveAll (line 61) | @Override
method findAll (line 69) | @Override
method findAll (line 74) | public List<T> findAll(Pageable pageable) {
method getPageSlice (line 100) | private List<T> getPageSlice(Pageable pageable, Collection<T> col) {
method count (line 122) | @Override
method delete (line 127) | @Override
method deleteAll (line 133) | @Override
method deleteAll (line 139) | @Override
method deleteById (line 144) | @Override
method findAllById (line 150) | @Override
method existsById (line 158) | @Override
method findOne (line 164) | public T findOne(ID id) {
method findById (line 169) | @Override
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/repository/OrderRepository.java
class OrderRepository (line 25) | @Repository
method OrderRepository (line 28) | public OrderRepository() {
method getEntityId (line 32) | @Override
method deleteAllById (line 38) | @Override
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/repository/PetRepository.java
class PetRepository (line 29) | @Repository
method PetRepository (line 34) | public PetRepository() {
method getEntityId (line 38) | @Override
method save (line 43) | @Override
method deleteAllById (line 55) | @Override
method findPetsByStatus (line 60) | public List<Pet> findPetsByStatus(List<Pet.StatusEnum> statusList) {
method findPetsByTags (line 67) | public List<Pet> findPetsByTags(List<String> tags) {
FILE: demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/repository/UserRepository.java
class UserRepository (line 25) | @Repository
method UserRepository (line 28) | public UserRepository() {
method getEntityId (line 32) | @Override
method deleteAllById (line 37) | @Override
FILE: demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/WebfluxDemoApplication.java
class WebfluxDemoApplication (line 34) | @SpringBootApplication
method main (line 38) | public static void main(String[] args) {
method customOpenAPI (line 42) | @Bean
method storeOpenApi (line 52) | @Bean
method userOpenApi (line 59) | @Bean
FILE: demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/controller/ExceptionTranslator.java
class ExceptionTranslator (line 31) | @RestControllerAdvice
method handleDuplicateKeyException (line 35) | @SuppressWarnings("rawtypes")
method handleTweetNotFoundException (line 43) | @SuppressWarnings("rawtypes")
FILE: demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/controller/TweetController.java
class TweetController (line 45) | @RestController
method TweetController (line 52) | public TweetController(TweetRepository tweetRepository, TweetMapper tw...
method getAllTweets (line 57) | @ApiResponses(value = { @ApiResponse(responseCode = "200", description...
method createTweets (line 64) | @PostMapping("/tweets")
method getTweetById (line 70) | @ApiResponses(value = { @ApiResponse(responseCode = "200", description...
method updateTweet (line 78) | @ApiResponses(value = { @ApiResponse(responseCode = "200", description...
method deleteTweet (line 90) | @ApiResponses(value = { @ApiResponse(responseCode = "200", description...
method streamAllTweets (line 100) | @Operation(description = "Tweets are Sent to the client as Server Sent...
FILE: demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/controller/TweetMapper.java
class TweetMapper (line 29) | @Component
method toDTO (line 32) | Flux<TweetDTO> toDTO(Flux<Tweet> tweet) {
method toEntity (line 36) | Flux<Tweet> toEntity(Flux<TweetDTO> tweetDTO) {
method toDTO (line 40) | Mono<TweetDTO> toDTO(Mono<Tweet> tweet) {
method toEntity (line 44) | Mono<Tweet> toEntity(Mono<TweetDTO> tweetDTO) {
method toDTO (line 48) | TweetDTO toDTO(Tweet tweet) {
method toEntity (line 54) | Tweet toEntity(TweetDTO tweetDTO) {
FILE: demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/dto/TweetDTO.java
class TweetDTO (line 31) | public class TweetDTO {
method TweetDTO (line 41) | public TweetDTO() {
method TweetDTO (line 45) | public TweetDTO(String text) {
method getId (line 49) | public String getId() {
method setId (line 53) | public void setId(String id) {
method getText (line 57) | public String getText() {
method setText (line 61) | public void setText(String text) {
method getCreatedAt (line 65) | public Date getCreatedAt() {
method setCreatedAt (line 69) | public void setCreatedAt(Date createdAt) {
FILE: demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/exception/TweetNotFoundException.java
class TweetNotFoundException (line 24) | public class TweetNotFoundException extends RuntimeException {
method TweetNotFoundException (line 31) | public TweetNotFoundException(String tweetId) {
FILE: demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/model/Tweet.java
class Tweet (line 34) | @Document(collection = "tweets")
method Tweet (line 46) | public Tweet() {
method Tweet (line 50) | public Tweet(String text) {
method getId (line 54) | public String getId() {
method setId (line 58) | public void setId(String id) {
method getText (line 62) | public String getText() {
method setText (line 66) | public void setText(String text) {
method getCreatedAt (line 70) | public Date getCreatedAt() {
method setCreatedAt (line 74) | public void setCreatedAt(Date createdAt) {
FILE: demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/payload/ErrorResponse.java
class ErrorResponse (line 24) | public class ErrorResponse {
method ErrorResponse (line 27) | public ErrorResponse(String message) {
method getMessage (line 31) | public String getMessage() {
method setMessage (line 35) | public void setMessage(String message) {
FILE: demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/repository/TweetRepository.java
type TweetRepository (line 29) | @Repository
FILE: demo-spring-boot-webmvc-scalar/src/main/java/org/springdoc/demo/services/book/SpringdocApplication.java
class SpringdocApplication (line 24) | @SpringBootApplication
method main (line 27) | public static void main(String[] args) {
FILE: demo-spring-boot-webmvc-scalar/src/main/java/org/springdoc/demo/services/book/controller/BookController.java
class BookController (line 45) | @RestController
method BookController (line 59) | public BookController(BookRepository repository) {
method findById (line 69) | @GetMapping("/{id}")
method findBooks (line 80) | @GetMapping("/")
method updateBook (line 92) | @PutMapping("/{id}")
method patchBook (line 105) | @PatchMapping("/{id}")
method postBook (line 117) | @PostMapping("/")
method headBook (line 128) | @RequestMapping(method = RequestMethod.HEAD, value = "/")
method deleteBook (line 140) | @DeleteMapping("/{id}")
FILE: demo-spring-boot-webmvc-scalar/src/main/java/org/springdoc/demo/services/book/exception/BookNotFoundException.java
class BookNotFoundException (line 21) | @SuppressWarnings("serial")
method BookNotFoundException (line 24) | public BookNotFoundException() {
FILE: demo-spring-boot-webmvc-scalar/src/main/java/org/springdoc/demo/services/book/exception/GlobalControllerExceptionHandler.java
class GlobalControllerExceptionHandler (line 31) | @RestControllerAdvice
method handleConnversion (line 34) | @ExceptionHandler(ConversionFailedException.class)
method handleBookNotFound (line 44) | @ExceptionHandler(BookNotFoundException.class)
FILE: demo-spring-boot-webmvc-scalar/src/main/java/org/springdoc/demo/services/book/model/Book.java
class Book (line 27) | public class Book {
method getId (line 53) | public long getId() {
method setId (line 62) | public void setId(long id) {
method getTitle (line 71) | public String getTitle() {
method setTitle (line 80) | public void setTitle(String title) {
method getAuthor (line 89) | public String getAuthor() {
method setAuthor (line 98) | public void setAuthor(String author) {
FILE: demo-spring-boot-webmvc-scalar/src/main/java/org/springdoc/demo/services/book/repository/BookRepository.java
class BookRepository (line 30) | @Repository
method findById (line 35) | public Optional<Book> findById(long id) {
method add (line 39) | public void add(Book book) {
method getBooks (line 43) | public Collection<Book> getBooks() {
FILE: demo-spring-cloud-function/spring-cloud-function-webflux/src/main/java/org/springdoc/demo/services/functions/PersonDTO.java
class PersonDTO (line 21) | public class PersonDTO {
method PersonDTO (line 28) | public PersonDTO() {
method PersonDTO (line 31) | public PersonDTO(final String email, final String firstName, final Str...
method getEmail (line 37) | public String getEmail() {
method setEmail (line 41) | public void setEmail(final String email) {
method getFirstName (line 45) | public String getFirstName() {
method setFirstName (line 49) | public void setFirstName(final String firstName) {
method getLastName (line 53) | public String getLastName() {
method setLastName (line 57) | public void setLastName(final String lastName) {
FILE: demo-spring-cloud-function/spring-cloud-function-webflux/src/main/java/org/springdoc/demo/services/functions/SampleApplication.java
class SampleApplication (line 17) | @SpringBootApplication()
method main (line 20) | public static void main(String[] args) {
method customOpenAPI (line 24) | @Bean
method reverseString (line 32) | @Bean
method uppercase (line 37) | @Bean
method lowercase (line 42) | @Bean
method hello (line 47) | @Bean
method words (line 52) | @Bean
FILE: demo-spring-cloud-function/spring-cloud-function-webmvc/src/main/java/org/springdoc/demo/services/functions/PersonDTO.java
class PersonDTO (line 21) | public class PersonDTO {
method PersonDTO (line 28) | public PersonDTO() {
method PersonDTO (line 31) | public PersonDTO(final String email, final String firstName, final Str...
method getEmail (line 37) | public String getEmail() {
method setEmail (line 41) | public void setEmail(final String email) {
method getFirstName (line 45) | public String getFirstName() {
method setFirstName (line 49) | public void setFirstName(final String firstName) {
method getLastName (line 53) | public String getLastName() {
method setLastName (line 57) | public void setLastName(final String lastName) {
FILE: demo-spring-cloud-function/spring-cloud-function-webmvc/src/main/java/org/springdoc/demo/services/functions/SampleApplication.java
class SampleApplication (line 28) | @SpringBootApplication()
method main (line 31) | public static void main(String[] args) {
method customOpenAPI (line 35) | @Bean
method reverseString (line 43) | @Bean
method uppercase (line 48) | @Bean
method lowercase (line 53) | @Bean
method helloSupplier (line 64) | @Bean
method helloConsumer (line 71) | @Bean
method words (line 76) | @Bean
FILE: demo-spring-data-rest/src/main/java/org/springdoc/demo/data/rest/Account.java
class Account (line 36) | @Entity
method getId (line 49) | public Long getId() {
method getCustomer (line 53) | public Customer getCustomer() {
method getExpiryDate (line 57) | public Date getExpiryDate() {
FILE: demo-spring-data-rest/src/main/java/org/springdoc/demo/data/rest/AccountRepository.java
type AccountRepository (line 39) | @RepositoryRestResource
method findByCustomer (line 49) | List<Account> findByCustomer(@Param("customer") Customer customer);
FILE: demo-spring-data-rest/src/main/java/org/springdoc/demo/data/rest/Customer.java
class Customer (line 12) | @Entity
method getId (line 23) | public Long getId() {
method getFirstname (line 27) | public String getFirstname() {
method getLastname (line 31) | public String getLastname() {
FILE: demo-spring-data-rest/src/main/java/org/springdoc/demo/data/rest/CustomerRepository.java
type CustomerRepository (line 41) | @RepositoryRestResource
method findByLastname (line 52) | Page<Customer> findByLastname(@Param("lastname") String lastname, Page...
method deleteById (line 54) | @Override
method delete (line 58) | @Override
FILE: demo-spring-data-rest/src/main/java/org/springdoc/demo/data/rest/SpringdocApplication.java
class SpringdocApplication (line 31) | @SpringBootApplication
method main (line 34) | public static void main(String[] args) {
method customOpenAPI (line 38) | @Bean
FILE: demo-spring-hateoas/src/main/java/org/springdoc/demo/services/hateoas/DatabaseLoader.java
class DatabaseLoader (line 29) | @Component
method init (line 38) | @Bean
FILE: demo-spring-hateoas/src/main/java/org/springdoc/demo/services/hateoas/Employee.java
class Employee (line 40) | @Data
method Employee (line 63) | Employee(String firstName, String lastName, String role) {
FILE: demo-spring-hateoas/src/main/java/org/springdoc/demo/services/hateoas/EmployeeController.java
class EmployeeController (line 49) | @RestController
method EmployeeController (line 54) | EmployeeController(EmployeeRepository repository) {
method findAll (line 62) | @GetMapping(path = "/employees", produces = MediaType.APPLICATION_JSON...
method newEmployee (line 76) | @PostMapping(path = "/employees", produces = MediaType.APPLICATION_JSO...
method findOne (line 101) | @GetMapping(path = "/employees/{id}", produces = MediaType.APPLICATION...
method updateEmployee (line 119) | @PutMapping(path = "/employees/{id}", produces = MediaType.APPLICATION...
FILE: demo-spring-hateoas/src/main/java/org/springdoc/demo/services/hateoas/EmployeeRepository.java
type EmployeeRepository (line 27) | interface EmployeeRepository extends CrudRepository<Employee, Long> {
FILE: demo-spring-hateoas/src/main/java/org/springdoc/demo/services/hateoas/SpringdocApplication.java
class SpringdocApplication (line 31) | @SpringBootApplication
method main (line 34) | public static void main(String[] args) {
method customOpenAPI (line 38) | @Bean
Condensed preview — 238 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (445K chars).
[
{
"path": ".gitattributes",
"chars": 154,
"preview": "#\n# https://help.github.com/articles/dealing-with-line-endings/\n#\n# These are explicitly windows files and should use cr"
},
{
"path": ".gitignore",
"chars": 1985,
"preview": "######################\n# Project Specific\n######################\n/target/www/**\n/src/test/javascript/coverage/\n\n########"
},
{
"path": "Jenkinsfile",
"chars": 386,
"preview": "#!/usr/bin/env groovy\n\nnode {\n\tstage('checkout') {\n\t\tdeleteDir()\n\t\tcheckout scm\n\t}\n\tstage('Clean') {\n\t\twithMaven(jdk: 'j"
},
{
"path": "LICENSE",
"chars": 11357,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 1530,
"preview": "[](https://ci-cd."
},
{
"path": "SUPPORT.md",
"chars": 637,
"preview": "## Where to get help\n\nIf you think you've found a bug in The Architect Theme,\nplease [check the existing issues](https:/"
},
{
"path": "demo-book-service/.gitignore",
"chars": 1881,
"preview": "######################\n# Project Specific\n######################\n/target/www/**\n/src/test/javascript/coverage/\n\n########"
},
{
"path": "demo-book-service/README.md",
"chars": 137,
"preview": "### Relevant Articles:\n\n- [Documenting a Spring REST API Using OpenAPI 3.0](https://www.baeldung.com/spring-rest-openapi"
},
{
"path": "demo-book-service/pom.xml",
"chars": 1650,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://m"
},
{
"path": "demo-book-service/src/main/java/org/springdoc/demo/services/book/SpringdocApplication.java",
"chars": 1000,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-book-service/src/main/java/org/springdoc/demo/services/book/controller/BookController.java",
"chars": 3677,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-book-service/src/main/java/org/springdoc/demo/services/book/exception/BookNotFoundException.java",
"chars": 852,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-book-service/src/main/java/org/springdoc/demo/services/book/exception/GlobalControllerExceptionHandler.java",
"chars": 2222,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-book-service/src/main/java/org/springdoc/demo/services/book/model/Book.java",
"chars": 1710,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-book-service/src/main/java/org/springdoc/demo/services/book/repository/BookRepository.java",
"chars": 1252,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-book-service/src/main/resources/application.yml",
"chars": 128,
"preview": "server:\n forward-headers-strategy: framework\n\nspringdoc:\n version: '@springdoc.version@'\n swagger-ui:\n use-root-pa"
},
{
"path": "demo-book-service/src/main/resources/logback.xml",
"chars": 439,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration>\n\t<appender name=\"STDOUT\" class=\"ch.qos.logback.core.ConsoleAppend"
},
{
"path": "demo-book-service/src/test/java/org/springdoc/demo/services/book/SwaggerUnitTest.java",
"chars": 1717,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-microservices/.gitignore",
"chars": 1881,
"preview": "######################\n# Project Specific\n######################\n/target/www/**\n/src/test/javascript/coverage/\n\n########"
},
{
"path": "demo-microservices/README.md",
"chars": 206,
"preview": "## sample microservices architecture using spring-cloud-gateway/eureka/spring-cloud-config\n\n### Relevant information:\n\n*"
},
{
"path": "demo-microservices/config-service/.gitignore",
"chars": 43,
"preview": "/target/\n/.classpath\n/.project\n/.settings/\n"
},
{
"path": "demo-microservices/config-service/pom.xml",
"chars": 605,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xsi:schem"
},
{
"path": "demo-microservices/config-service/src/main/java/org/springdoc/demo/services/config/ConfigApplication.java",
"chars": 440,
"preview": "package org.springdoc.demo.services.config;\n\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\nimport"
},
{
"path": "demo-microservices/config-service/src/main/resources/application.yml",
"chars": 59,
"preview": "server:\n port: 8088\nspring:\n profiles:\n active: native"
},
{
"path": "demo-microservices/config-service/src/main/resources/config/department-service.yml",
"chars": 359,
"preview": "server:\n port: 8090\n forward-headers-strategy: framework\neureka:\n client:\n serviceUrl:\n defaultZone: ${EUREKA"
},
{
"path": "demo-microservices/config-service/src/main/resources/config/discovery-service.yml",
"chars": 212,
"preview": "server:\n port: 8761\n forward-headers-strategy: framework\neureka:\n client:\n serviceUrl:\n defaultZone: ${EUREKA"
},
{
"path": "demo-microservices/config-service/src/main/resources/config/employee-service.yml",
"chars": 359,
"preview": "server:\n port: 8092\n forward-headers-strategy: framework\neureka:\n client:\n serviceUrl:\n defaultZone: ${EUREKA"
},
{
"path": "demo-microservices/config-service/src/main/resources/config/gateway-service.yml",
"chars": 2470,
"preview": "server:\n port: 8060\n forward-headers-strategy: framework\n\neureka:\n client:\n serviceUrl:\n defaultZone: ${EUREK"
},
{
"path": "demo-microservices/config-service/src/main/resources/config/organization-service.yml",
"chars": 360,
"preview": "server:\n port: 8091\n forward-headers-strategy: framework\n\neureka:\n client:\n serviceUrl:\n defaultZone: ${EUREK"
},
{
"path": "demo-microservices/department-service/.gitignore",
"chars": 43,
"preview": "/target/\n/.classpath\n/.project\n/.settings/\n"
},
{
"path": "demo-microservices/department-service/pom.xml",
"chars": 1430,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xsi:schem"
},
{
"path": "demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/DepartmentApplication.java",
"chars": 1305,
"preview": "package org.springdoc.demo.services.department;\n\nimport io.swagger.v3.oas.annotations.OpenAPIDefinition;\nimport io.swagg"
},
{
"path": "demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/client/EmployeeClient.java",
"chars": 524,
"preview": "package org.springdoc.demo.services.department.client;\n\nimport java.util.List;\n\nimport org.springdoc.demo.services.depar"
},
{
"path": "demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/controller/DepartmentController.java",
"chars": 2230,
"preview": "package org.springdoc.demo.services.department.controller;\n\nimport java.util.List;\n\nimport org.slf4j.Logger;\nimport org."
},
{
"path": "demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/model/Department.java",
"chars": 1073,
"preview": "package org.springdoc.demo.services.department.model;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class "
},
{
"path": "demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/model/Employee.java",
"chars": 870,
"preview": "package org.springdoc.demo.services.department.model;\n\npublic class Employee {\n\n\tprivate Long id;\n\n\tprivate String name;"
},
{
"path": "demo-microservices/department-service/src/main/java/org/springdoc/demo/services/department/repository/DepartmentRepository.java",
"chars": 976,
"preview": "package org.springdoc.demo.services.department.repository;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport ja"
},
{
"path": "demo-microservices/department-service/src/main/resources/application.yml",
"chars": 138,
"preview": "spring:\n application:\n name: department-service\n config:\n import: \"optional:configserver:${CONFIG_SERVER:http://"
},
{
"path": "demo-microservices/discovery-service/.gitignore",
"chars": 43,
"preview": "/target/\n/.settings/\n/.classpath\n/.project\n"
},
{
"path": "demo-microservices/discovery-service/pom.xml",
"chars": 759,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xsi:schem"
},
{
"path": "demo-microservices/discovery-service/src/main/java/org/springdoc/demo/services/discovery/DiscoveryApplication.java",
"chars": 457,
"preview": "package org.springdoc.demo.services.discovery;\n\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\nimp"
},
{
"path": "demo-microservices/discovery-service/src/main/resources/application.yml",
"chars": 135,
"preview": "spring:\n application:\n name: discovery-service\n config:\n import: \"optional:configserver:${CONFIG_SERVER:http://l"
},
{
"path": "demo-microservices/employee-service/.gitignore",
"chars": 43,
"preview": "/target/\n/.classpath\n/.project\n/.settings/\n"
},
{
"path": "demo-microservices/employee-service/pom.xml",
"chars": 1155,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xsi:schem"
},
{
"path": "demo-microservices/employee-service/src/main/java/org/springdoc/demo/services/employee/EmployeeApplication.java",
"chars": 1713,
"preview": "package org.springdoc.demo.services.employee;\n\nimport io.swagger.v3.oas.annotations.OpenAPIDefinition;\nimport io.swagger"
},
{
"path": "demo-microservices/employee-service/src/main/java/org/springdoc/demo/services/employee/controller/EmployeeController.java",
"chars": 1821,
"preview": "package org.springdoc.demo.services.employee.controller;\n\nimport java.util.List;\n\nimport org.slf4j.Logger;\nimport org.sl"
},
{
"path": "demo-microservices/employee-service/src/main/java/org/springdoc/demo/services/employee/model/Employee.java",
"chars": 1434,
"preview": "package org.springdoc.demo.services.employee.model;\n\npublic class Employee {\n\n\tprivate Long id;\n\n\tprivate Long organizat"
},
{
"path": "demo-microservices/employee-service/src/main/java/org/springdoc/demo/services/employee/repository/EmployeeRepository.java",
"chars": 1105,
"preview": "package org.springdoc.demo.services.employee.repository;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java"
},
{
"path": "demo-microservices/employee-service/src/main/resources/application.yml",
"chars": 135,
"preview": "spring:\n application:\n name: employee-service\n config:\n import: \"optional:configserver:${CONFIG_SERVER:http://lo"
},
{
"path": "demo-microservices/gateway-service/.gitignore",
"chars": 43,
"preview": "/target/\n/.classpath\n/.project\n/.settings/\n"
},
{
"path": "demo-microservices/gateway-service/pom.xml",
"chars": 1025,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xsi:schem"
},
{
"path": "demo-microservices/gateway-service/src/main/java/org/springdoc/demo/services/gateway/ContextPathRewritePathGatewayFilterFactory.java",
"chars": 1277,
"preview": "package org.springdoc.demo.services.gateway;\n\nimport org.springframework.cloud.gateway.filter.GatewayFilter;\nimport org."
},
{
"path": "demo-microservices/gateway-service/src/main/java/org/springdoc/demo/services/gateway/GatewayApplication.java",
"chars": 1601,
"preview": "package org.springdoc.demo.services.gateway;\n\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Set;\n\nim"
},
{
"path": "demo-microservices/gateway-service/src/main/resources/application.yml",
"chars": 134,
"preview": "spring:\n application:\n name: gateway-service\n config:\n import: \"optional:configserver:${CONFIG_SERVER:http://loc"
},
{
"path": "demo-microservices/organization-service/.gitignore",
"chars": 43,
"preview": "/target/\n/.classpath\n/.project\n/.settings/\n"
},
{
"path": "demo-microservices/organization-service/pom.xml",
"chars": 1432,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xsi:schem"
},
{
"path": "demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/OrganizationApplication.java",
"chars": 1275,
"preview": "package org.springdoc.demo.services.organization;\n\nimport io.swagger.v3.oas.annotations.OpenAPIDefinition;\nimport io.swa"
},
{
"path": "demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/client/DepartmentClient.java",
"chars": 727,
"preview": "package org.springdoc.demo.services.organization.client;\n\nimport java.util.List;\n\nimport org.springdoc.demo.services.org"
},
{
"path": "demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/client/EmployeeClient.java",
"chars": 538,
"preview": "package org.springdoc.demo.services.organization.client;\n\nimport java.util.List;\n\nimport org.springdoc.demo.services.org"
},
{
"path": "demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/controller/OrganizationController.java",
"chars": 2780,
"preview": "package org.springdoc.demo.services.organization.controller;\n\nimport java.util.List;\n\nimport org.slf4j.Logger;\nimport or"
},
{
"path": "demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/model/Department.java",
"chars": 782,
"preview": "package org.springdoc.demo.services.organization.model;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic clas"
},
{
"path": "demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/model/Employee.java",
"chars": 872,
"preview": "package org.springdoc.demo.services.organization.model;\n\npublic class Employee {\n\n\tprivate Long id;\n\n\tprivate String nam"
},
{
"path": "demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/model/Organization.java",
"chars": 1224,
"preview": "package org.springdoc.demo.services.organization.model;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic clas"
},
{
"path": "demo-microservices/organization-service/src/main/java/org/springdoc/demo/services/organization/repository/OrganizationRepository.java",
"chars": 795,
"preview": "package org.springdoc.demo.services.organization.repository;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport "
},
{
"path": "demo-microservices/organization-service/src/main/resources/application.yml",
"chars": 139,
"preview": "spring:\n application:\n name: organization-service\n config:\n import: \"optional:configserver:${CONFIG_SERVER:http:"
},
{
"path": "demo-microservices/pom.xml",
"chars": 758,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://m"
},
{
"path": "demo-oauth2/.gitignore",
"chars": 1881,
"preview": "######################\n# Project Specific\n######################\n/target/www/**\n/src/test/javascript/coverage/\n\n########"
},
{
"path": "demo-oauth2/README.md",
"chars": 946,
"preview": "## Spring Security OAuth - New Stack\n\n### Relevant information:\n\n1. `oauth-authorization-server` is a Keycloak Authoriza"
},
{
"path": "demo-oauth2/oauth-authorization-server/.gitignore",
"chars": 1881,
"preview": "######################\n# Project Specific\n######################\n/target/www/**\n/src/test/javascript/coverage/\n\n########"
},
{
"path": "demo-oauth2/oauth-authorization-server/pom.xml",
"chars": 1120,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xsi:schem"
},
{
"path": "demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/AuthorizationServerApp.java",
"chars": 325,
"preview": "package org.springdoc.demo.auth;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.aut"
},
{
"path": "demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/DefaultSecurityConfig.java",
"chars": 1421,
"preview": "package org.springdoc.demo.auth;\n\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.context"
},
{
"path": "demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/Jwks.java",
"chars": 618,
"preview": "package org.springdoc.demo.auth;\n\nimport java.security.KeyPair;\nimport java.security.interfaces.RSAPrivateKey;\nimport ja"
},
{
"path": "demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/KeyGeneratorUtils.java",
"chars": 1822,
"preview": "package org.springdoc.demo.auth;\n\nimport java.math.BigInteger;\nimport java.security.KeyPair;\nimport java.security.KeyPai"
},
{
"path": "demo-oauth2/oauth-authorization-server/src/main/java/org/springdoc/demo/auth/SecurityConfig.java",
"chars": 7298,
"preview": "package org.springdoc.demo.auth;\n\nimport java.util.List;\nimport java.util.UUID;\n\nimport com.nimbusds.jose.jwk.JWKSet;\nim"
},
{
"path": "demo-oauth2/oauth-authorization-server/src/main/resources/application.yml",
"chars": 455,
"preview": "spring:\n datasource:\n username: sa\n url: jdbc:h2:./data/keycloak;DB_CLOSE_ON_EXIT=FALSE\n hikari:\n maximum"
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/.gitignore",
"chars": 1881,
"preview": "######################\n# Project Specific\n######################\n/target/www/**\n/src/test/javascript/coverage/\n\n########"
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/pom.xml",
"chars": 1207,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xsi:schem"
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/ResourceServerApp.java",
"chars": 909,
"preview": "package org.springdoc.demo.resource;\n\nimport io.swagger.v3.oas.models.Components;\nimport io.swagger.v3.oas.models.OpenAP"
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/config/OpenApiConfig.java",
"chars": 1667,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/config/SecurityConfig.java",
"chars": 897,
"preview": "package org.springdoc.demo.resource.config;\n\nimport org.springframework.context.annotation.Bean;\nimport org.springframew"
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/model/Foo.java",
"chars": 1405,
"preview": "package org.springdoc.demo.resource.model;\n\nimport jakarta.persistence.Entity;\nimport jakarta.persistence.GeneratedValue"
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/repository/IFooRepository.java",
"chars": 336,
"preview": "package org.springdoc.demo.resource.repository;\n\nimport org.springdoc.demo.resource.model.Foo;\n\nimport org.springframewo"
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/service/IFooService.java",
"chars": 238,
"preview": "package org.springdoc.demo.resource.service;\n\nimport java.util.Optional;\n\nimport org.springdoc.demo.resource.model.Foo;\n"
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/service/impl/FooServiceImpl.java",
"chars": 747,
"preview": "package org.springdoc.demo.resource.service.impl;\n\nimport java.util.Optional;\n\nimport org.springdoc.demo.resource.model."
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/web/controller/FooController.java",
"chars": 2385,
"preview": "package org.springdoc.demo.resource.web.controller;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport jav"
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/web/controller/UserInfoController.java",
"chars": 719,
"preview": "package org.springdoc.demo.resource.web.controller;\n\nimport java.util.Collections;\nimport java.util.Map;\n\nimport io.swag"
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/src/main/java/org/springdoc/demo/resource/web/dto/FooDTO.java",
"chars": 461,
"preview": "package org.springdoc.demo.resource.web.dto;\n\npublic class FooDTO {\n\tprivate long id;\n\n\tprivate String name;\n\n\tpublic Fo"
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/src/main/resources/application.yml",
"chars": 617,
"preview": "server:\n forward-headers-strategy: framework\n port: 8082\n\n####### resource server configuration properties\nspring:\n w"
},
{
"path": "demo-oauth2/oauth-resource-server-webflux/src/main/resources/data.sql",
"chars": 142,
"preview": "INSERT INTO Foo(id, name)\nVALUES (1, 'Foo 1');\nINSERT INTO Foo(id, name)\nVALUES (2, 'Foo 2');\nINSERT INTO Foo(id, name)\n"
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/.gitignore",
"chars": 1881,
"preview": "######################\n# Project Specific\n######################\n/target/www/**\n/src/test/javascript/coverage/\n\n########"
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/pom.xml",
"chars": 1201,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xsi:schem"
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/ResourceServerApp.java",
"chars": 338,
"preview": "package org.springdoc.demo.resource;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot"
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/config/OpenApiConfig.java",
"chars": 1651,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/config/SecurityConfig.java",
"chars": 1018,
"preview": "package org.springdoc.demo.resource.config;\n\nimport org.springframework.context.annotation.Bean;\nimport org.springframew"
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/model/Foo.java",
"chars": 1425,
"preview": "package org.springdoc.demo.resource.model;\n\nimport java.util.UUID;\n\nimport jakarta.persistence.Entity;\nimport jakarta.pe"
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/repository/IFooRepository.java",
"chars": 336,
"preview": "package org.springdoc.demo.resource.repository;\n\nimport org.springdoc.demo.resource.model.Foo;\n\nimport org.springframewo"
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/service/IFooService.java",
"chars": 238,
"preview": "package org.springdoc.demo.resource.service;\n\nimport java.util.Optional;\n\nimport org.springdoc.demo.resource.model.Foo;\n"
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/service/impl/FooServiceImpl.java",
"chars": 747,
"preview": "package org.springdoc.demo.resource.service.impl;\n\nimport java.util.Optional;\n\nimport org.springdoc.demo.resource.model."
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/web/controller/FooController.java",
"chars": 2385,
"preview": "package org.springdoc.demo.resource.web.controller;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport jav"
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/web/controller/UserInfoController.java",
"chars": 719,
"preview": "package org.springdoc.demo.resource.web.controller;\n\nimport java.util.Collections;\nimport java.util.Map;\n\nimport io.swag"
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/src/main/java/org/springdoc/demo/resource/web/dto/FooDTO.java",
"chars": 474,
"preview": "package org.springdoc.demo.resource.web.dto;\n\nimport java.util.UUID;\n\npublic class FooDTO {\n\tprivate UUID id;\n\n\tprivate "
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/src/main/resources/application.yml",
"chars": 620,
"preview": "server:\n port: 8081\n forward-headers-strategy: framework\n servlet:\n context-path: /resource-server\n\n####### resour"
},
{
"path": "demo-oauth2/oauth-resource-server-webmvc/src/main/resources/data.sql",
"chars": 253,
"preview": "INSERT INTO Foo(id, name)\nVALUES ('dc58c780-a571-437e-85e2-9be232c5cd80', 'Foo 1');\nINSERT INTO Foo(id, name)\nVALUES ('d"
},
{
"path": "demo-oauth2/pom.xml",
"chars": 959,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://m"
},
{
"path": "demo-person-service/.gitattributes",
"chars": 154,
"preview": "#\n# https://help.github.com/articles/dealing-with-line-endings/\n#\n# These are explicitly windows files and should use cr"
},
{
"path": "demo-person-service/.gitignore",
"chars": 1881,
"preview": "######################\n# Project Specific\n######################\n/target/www/**\n/src/test/javascript/coverage/\n\n########"
},
{
"path": "demo-person-service/README.md",
"chars": 329,
"preview": "### Relevant Articles:\n\n- [DZone Part1](https://dzone.com/articles/openapi-3-documentation-with-spring-boot)\n- [DZone Pa"
},
{
"path": "demo-person-service/pom.xml",
"chars": 1464,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://m"
},
{
"path": "demo-person-service/src/main/java/org/springdoc/demo/services/person/SampleApplication.java",
"chars": 1070,
"preview": "package org.springdoc.demo.services.person;\n\nimport io.swagger.v3.oas.models.Components;\nimport io.swagger.v3.oas.models"
},
{
"path": "demo-person-service/src/main/java/org/springdoc/demo/services/person/config/SampleConfig.java",
"chars": 715,
"preview": "package org.springdoc.demo.services.person.config;\n\nimport javax.money.MonetaryAmount;\n\nimport jakarta.annotation.PostCo"
},
{
"path": "demo-person-service/src/main/java/org/springdoc/demo/services/person/controller/PersonController.java",
"chars": 1350,
"preview": "package org.springdoc.demo.services.person.controller;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.u"
},
{
"path": "demo-person-service/src/main/java/org/springdoc/demo/services/person/exceptions/ErrorMessage.java",
"chars": 586,
"preview": "package org.springdoc.demo.services.person.exceptions;\n\nimport java.util.Arrays;\nimport java.util.Collections;\nimport ja"
},
{
"path": "demo-person-service/src/main/java/org/springdoc/demo/services/person/exceptions/GlobalControllerAdvice.java",
"chars": 4959,
"preview": "package org.springdoc.demo.services.person.exceptions;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.u"
},
{
"path": "demo-person-service/src/main/java/org/springdoc/demo/services/person/exceptions/Problem.java",
"chars": 524,
"preview": "package org.springdoc.demo.services.person.exceptions;\n\npublic class Problem {\n\n\tprivate String logRef;\n\n\tprivate String"
},
{
"path": "demo-person-service/src/main/java/org/springdoc/demo/services/person/model/Person.java",
"chars": 1624,
"preview": "package org.springdoc.demo.services.person.model;\n\nimport javax.money.MonetaryAmount;\n\nimport com.fasterxml.jackson.anno"
},
{
"path": "demo-person-service/src/main/resources/application.properties",
"chars": 120,
"preview": "springdoc.version=@springdoc.version@\nspringdoc.swagger-ui.use-root-path=true\nserver.forward-headers-strategy=framework\n"
},
{
"path": "demo-spring-boot-3-webflux/.gitignore",
"chars": 1881,
"preview": "######################\n# Project Specific\n######################\n/target/www/**\n/src/test/javascript/coverage/\n\n########"
},
{
"path": "demo-spring-boot-3-webflux/.java-version",
"chars": 17,
"preview": "graalvm64-17.0.5\n"
},
{
"path": "demo-spring-boot-3-webflux/README.md",
"chars": 725,
"preview": "# springdoc-openapi demo with spring-boot-2 web-flux\n\n## Building application\n\n### Pre-requisites\n\n- JDK 8+\n- maven 3\n- "
},
{
"path": "demo-spring-boot-3-webflux/pom.xml",
"chars": 2126,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xsi:schem"
},
{
"path": "demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/WebfluxDemoApplication.java",
"chars": 2346,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/controller/ExceptionTranslator.java",
"chars": 1813,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/controller/TweetController.java",
"chars": 4607,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/controller/TweetMapper.java",
"chars": 1633,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/dto/TweetDTO.java",
"chars": 1479,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/exception/TweetNotFoundException.java",
"chars": 976,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/model/Tweet.java",
"chars": 1621,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/payload/ErrorResponse.java",
"chars": 994,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webflux/src/main/java/org/springdoc/demo/app3/repository/TweetRepository.java",
"chars": 1029,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webflux/src/main/resources/META-INF/native-image/reflect-config.json",
"chars": 65,
"preview": "[\n {\n \"name\": \"org.springdoc.demo.app3.dto.TweetDTO[]\"\n }\n]\n"
},
{
"path": "demo-spring-boot-3-webflux/src/main/resources/application.yml",
"chars": 244,
"preview": "server:\n port: 8082\n forward-headers-strategy: framework\n\nspring:\n data:\n mongodb:\n uri: ${SPRING_DATA_MONGOD"
},
{
"path": "demo-spring-boot-3-webflux-functional/.gitignore",
"chars": 1881,
"preview": "######################\n# Project Specific\n######################\n/target/www/**\n/src/test/javascript/coverage/\n\n########"
},
{
"path": "demo-spring-boot-3-webflux-functional/pom.xml",
"chars": 1813,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://m"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/AppNativeConfiguration.java",
"chars": 1433,
"preview": "package org.springdoc.demo.app4;\n\nimport java.util.Arrays;\n\nimport org.springdoc.demo.app4.AppNativeConfiguration.AppNat"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/WebfluxFunctionalDemoApplication.java",
"chars": 2218,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/Coffee.java",
"chars": 1000,
"preview": "package org.springdoc.demo.app4.coffee;\n\nimport java.util.Objects;\n\nimport org.springframework.data.annotation.Id;\n\npubl"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/CoffeeOrder.java",
"chars": 969,
"preview": "package org.springdoc.demo.app4.coffee;\n\nimport java.time.Instant;\nimport java.util.Objects;\n\npublic class CoffeeOrder {"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/CoffeeRepository.java",
"chars": 203,
"preview": "package org.springdoc.demo.app4.coffee;\n\nimport org.springframework.data.repository.reactive.ReactiveCrudRepository;\n\npu"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/CoffeeService.java",
"chars": 865,
"preview": "package org.springdoc.demo.app4.coffee;\n\nimport java.time.Duration;\nimport java.time.Instant;\n\nimport io.swagger.v3.oas."
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/coffee/RouteConfig.java",
"chars": 1667,
"preview": "package org.springdoc.demo.app4.coffee;\n\nimport reactor.core.publisher.Mono;\n\nimport org.springframework.context.annotat"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/employee/Employee.java",
"chars": 280,
"preview": "package org.springdoc.demo.app4.employee;\n\nimport lombok.AllArgsConstructor;\nimport lombok.Data;\nimport lombok.NoArgsCon"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/employee/EmployeeFunctionalConfig.java",
"chars": 3514,
"preview": "package org.springdoc.demo.app4.employee;\n\n\nimport java.util.function.Consumer;\n\nimport io.swagger.v3.oas.annotations.en"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/employee/EmployeeRepository.java",
"chars": 2190,
"preview": "package org.springdoc.demo.app4.employee;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport io.swagger.v3.oas.ann"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/user/RoutingConfiguration.java",
"chars": 1524,
"preview": "package org.springdoc.demo.app4.user;\n\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.co"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/user/User.java",
"chars": 958,
"preview": "package org.springdoc.demo.app4.user;\n\npublic class User {\n\tprivate long id;\n\n\tprivate String firstname;\n\n\tprivate Strin"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/user/UserHandler.java",
"chars": 2725,
"preview": "package org.springdoc.demo.app4.user;\n\nimport reactor.core.publisher.Flux;\nimport reactor.core.publisher.Mono;\n\nimport o"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/user/UserRepository.java",
"chars": 879,
"preview": "package org.springdoc.demo.app4.user;\n\nimport io.swagger.v3.oas.annotations.Operation;\nimport io.swagger.v3.oas.annotati"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/java/org/springdoc/demo/app4/user/UserRepositoryImpl.java",
"chars": 1727,
"preview": "package org.springdoc.demo.app4.user;\n\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.stream.Collector"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/resources/application.yml",
"chars": 370,
"preview": "server:\n servlet:\n context-path: /\n compression:\n enabled: true\n mime-types: text/html,text/xml,text/plain,te"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/resources/logback-spring.xml",
"chars": 2145,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE configuration>\n\n<configuration scan=\"true\">\n\n\t<appender name=\"STDOUT\"\n\t"
},
{
"path": "demo-spring-boot-3-webflux-functional/src/main/resources/schema.sql",
"chars": 81,
"preview": "CREATE TABLE COFFEE\n(\n id VARCHAR(255) PRIMARY KEY,\n name VARCHAR(255)\n);"
},
{
"path": "demo-spring-boot-3-webmvc/.gitignore",
"chars": 9,
"preview": "/target/\n"
},
{
"path": "demo-spring-boot-3-webmvc/.java-version",
"chars": 17,
"preview": "graalvm64-17.0.5\n"
},
{
"path": "demo-spring-boot-3-webmvc/README.md",
"chars": 722,
"preview": "# springdoc-openapi demo with spring-boot-2 web-mvc\n\n## Building application\n\n### Pre-requisites\n\n- JDK 8+\n- maven 3\n- d"
},
{
"path": "demo-spring-boot-3-webmvc/pom.xml",
"chars": 1631,
"preview": "<project xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xsi:schem"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/Application.java",
"chars": 2696,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/ApiUtil.java",
"chars": 1592,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/ExceptionTranslator.java",
"chars": 1902,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/PetApi.java",
"chars": 11358,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/PetApiController.java",
"chars": 1316,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/PetApiDelegate.java",
"chars": 4330,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/PetApiDelegateImpl.java",
"chars": 6809,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/StoreApi.java",
"chars": 4897,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/StoreApiController.java",
"chars": 1330,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/StoreApiDelegate.java",
"chars": 2795,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/StoreApiDelegateImpl.java",
"chars": 3410,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/UserApi.java",
"chars": 7903,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/UserApiController.java",
"chars": 1323,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/UserApiDelegate.java",
"chars": 3548,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/api/UserApiDelegateImpl.java",
"chars": 4440,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/Body.java",
"chars": 2201,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/Body1.java",
"chars": 2396,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/Category.java",
"chars": 2917,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/ModelApiResponse.java",
"chars": 3565,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/Order.java",
"chars": 5812,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/Pet.java",
"chars": 6181,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/Tag.java",
"chars": 2824,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/model/User.java",
"chars": 6281,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/repository/HashMapRepository.java",
"chars": 4861,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/repository/OrderRepository.java",
"chars": 1114,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/repository/PetRepository.java",
"chars": 2031,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/java/org/springdoc/demo/app2/repository/UserRepository.java",
"chars": 1117,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/resources/application.yml",
"chars": 488,
"preview": "management:\n endpoints:\n web:\n base-path: /rest/actuator\n exposure:\n include: '*'\n\nspringdoc:\n ver"
},
{
"path": "demo-spring-boot-3-webmvc/src/main/resources/petstore.yml",
"chars": 20549,
"preview": "openapi: 3.0.2\ninfo:\n title: Swagger Petstore - OpenAPI 3.0\n description: |-\n This is a sample Pet Store Server bas"
},
{
"path": "demo-spring-boot-webflux-scalar/pom.xml",
"chars": 1595,
"preview": "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xsi:schem"
},
{
"path": "demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/WebfluxDemoApplication.java",
"chars": 2346,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/controller/ExceptionTranslator.java",
"chars": 1813,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/controller/TweetController.java",
"chars": 4607,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/controller/TweetMapper.java",
"chars": 1633,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/dto/TweetDTO.java",
"chars": 1479,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/exception/TweetNotFoundException.java",
"chars": 976,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/model/Tweet.java",
"chars": 1621,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/payload/ErrorResponse.java",
"chars": 994,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-webflux-scalar/src/main/java/org/springdoc/demo/app3/repository/TweetRepository.java",
"chars": 1029,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
},
{
"path": "demo-spring-boot-webflux-scalar/src/main/resources/application.yml",
"chars": 206,
"preview": "server:\n port: 8082\n forward-headers-strategy: framework\n\nspring:\n data:\n mongodb:\n uri: ${SPRING_DATA_MONGOD"
},
{
"path": "demo-spring-boot-webflux-scalar/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst",
"chars": 481,
"preview": "org/springdoc/demo/app3/dto/TweetDTO.class\norg/springdoc/demo/app3/controller/ExceptionTranslator.class\norg/springdoc/de"
},
{
"path": "demo-spring-boot-webflux-scalar/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst",
"chars": 1534,
"preview": "/Users/Badr.NassLahsen/Documents/workspace/main/springdoc-openapi-demos/demo-spring-boot-webflux-scalar/src/main/java/or"
},
{
"path": "demo-spring-boot-webmvc-scalar/pom.xml",
"chars": 1092,
"preview": "<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n\t\t xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\t\t xsi:schem"
},
{
"path": "demo-spring-boot-webmvc-scalar/src/main/java/org/springdoc/demo/services/book/SpringdocApplication.java",
"chars": 1000,
"preview": "/*\n *\n * * Copyright 2019-2020 the original author or authors.\n * *\n * * Licensed under the Apache License, Version 2"
}
]
// ... and 38 more files (download for full content)
About this extraction
This page contains the full source code of the springdoc/springdoc-openapi-demos GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 238 files (382.0 KB), approximately 105.0k tokens, and a symbol index with 879 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.