- Следующие зависимости используются в Сервисах: < /li>
< /ul>Swagger UI доступен по адресу url http: // localhost: 8765/swagger-ui/index.htmlКод: Выделить всё
implementation 'org.springframework.boot:spring-boot-starter-web' // SpringDoc OpenAPI implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.6' < /code> В Api Gateway: < /li> < /ul> implementation 'org.springframework.boot:spring-boot-starter-webflux' implementation 'org.springframework.cloud:spring-cloud-starter-gateway' implementation 'org.springframework.cloud:spring-cloud-starter-openfeign' implementation 'org.springframework.cloud:spring-cloud-starter-loadbalancer' implementation 'org.springframework.cloud:spring-cloud-starter-circuitbreaker-reactor-resilience4j' implementation 'org.springframework.cloud:spring-cloud-starter-config' // SpringDoc OpenAPI implementation 'org.springdoc:springdoc-openapi-starter-webflux-ui:2.8.6' < /code> Свойства в службах < /li> < /ul> spring: application: name: server: port: springdoc: api-docs: enabled: true path: /v3/api-docs < /code> Свойство в API Gateway < /li> < /ul> spring: application: name: api-gateway server: port: 8765 cloud: gateway: httpclient: response-timeout: 5s routes: - id: api-gateway-route uri: http://api-gateway:8765 (I don't know how to insert // characters on stackoverflow) predicates: - Path=/gateway/** filters: - RewritePath=/gateway/(?.*), /${segment} - name: Retry args: retries: 3 statuses: BAD_GATEWAY, SERVICE_UNAVAILABLE methods: GET, POST - name: CircuitBreaker args: name: apiGatewayCircuitBreaker fallbackUri: forward:/fallback/gateway - id: resume-analyzer-route uri: http://resume-analyzer:8083 predicates: - Path=/analyzer/** filters: - RewritePath=/analyzer/(?.*), /${segment} - name: Retry args: retries: 3 statuses: BAD_GATEWAY, SERVICE_UNAVAILABLE methods: GET, POST - name: CircuitBreaker args: name: resumeAnalyzerCircuitBreaker fallbackUri: forward:/fallback/analyzer - id: resume-generator-route uri: http://resume-generator:8082 predicates: - Path=/generator/** filters: - RewritePath=/generator/(?.*), /${segment} - name: Retry args: retries: 3 statuses: BAD_GATEWAY, SERVICE_UNAVAILABLE methods: GET, POST - name: CircuitBreaker args: name: resumeGeneratorCircuitBreaker fallbackUri: forward:/fallback/generator - id: deepseek-service-route uri: http://deepseek-service:9090 predicates: - Path=/deepseek/** filters: - RewritePath=/deepseek/(?.*), /${segment} - name: Retry args: retries: 3 statuses: BAD_GATEWAY, SERVICE_UNAVAILABLE methods: GET, POST - name: CircuitBreaker args: name: deepseekServiceCircuitBreaker fallbackUri: forward:/fallback/deepseek springdoc: api-docs: enabled: true path: /v3/api-docs swagger-ui: enabled: true config-url: /v3/api-docs/swagger-config urls: - name: api gateway url: /gateway/v3/api-docs - name: resume analyzer url: /analyzer/v3/api-docs - name: resume generator url: /generator/v3/api-docs - name: deepseek service url: /deepseek/v3/api-docs
in swagger ui я могу переключаться между службами API, используя выпадающий список. Но когда я пытаюсь выполнить запрос из документации, я получаю ошибку:
swagger-ui-bundle.js:2
gat http: // api-gateway: 8765/api/net :: err_name_not_resolved
/>
Я изменил маршруты в свойстве API Gateway, если я заменяю «LocalHost» вместо API-Gateway и имена услуг в URI, то у меня есть доступ только к документации от Gateway APE, запросы, в которых обрабатывается правильно (HTTP Statest 200), но при изменении шлюза API-вдаль на любую услугу я получаю ошибку, не отображается. /> Я читаю Swagger UI и OpenAPI документацию, но я не смог найти подходящий пример
- Доступ ко всей документации (Услуги и API) через один url (http: // localhost: 87655. - достигнуто
- Рабочие запросы от Swagger UI - Нужна ваша помощь
Подробнее здесь: https://stackoverflow.com/questions/795 ... t-services