Springdoc with multiple api-docs - springdoc

I want to group three API docs in one swagger-ui. I use Springdoc. Each of the three API-docs has its own url. (They are not in the same project).
Is there a way to do this?
Edit: It's now working this way:
springdoc:
swagger-ui:
path: /
urls:
- name: App1
url: http://app1.domain.com/v3/api-docs
- name: App2
url: http://app2.domain.com/v3/api-docs
- name: App3
url: http://app3.domain.com/v3/api-docs

The answer is already available on the F.A.Q:
https://springdoc.org/faq.html#how-can-i-agreagte-external-endpoints-exposing-openapi-3-spec-inside-one-single-application
The properties springdoc.swagger-ui.urls.*, are suitable to configure external (/v3/api-docs url):
For example if you want to agreagte all the endpoints of other services, inside one single application. Don’t forget that CORS needs to be enabled as well.
Details of the properties are available here:
https://springdoc.org/springdoc-properties.html

Related

Error Static file referenced by handler not found: dist/api/landing for Angular App deployed on Google Cloud

please help, I do not have experience deploying, I have been trying for days, bear with me. Thanks.
I have been working on a angular app with flask backend and both work proper locally, I need to deploy them. The server is written in flask and it is accessible via Postman. The page renders properly from "https://apt-trainer-279210.uc.r.appspot.com/" but on API call an error 404 not found when calling "api/landing" to my server. Going to the logs on GAE I see error.
Static file referenced by handler not found: dist/api/landing
I am guessing that its looking for file in the above path but it should be calling my server instead. Below is my app.yaml file for angular:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: dist/index.html
upload: dist/index.html
- url: /
static_dir: dist
skip_files:
- e2e/
- node_modules/
- src/
- coverage
- ^(.*/)?\..*$
- ^(.*/)?.*\.json$
- ^(.*/)?.*\.md$
- ^(.*/)?.*\.yaml$
- ^LICENSE
Also note that in the angular app I proxy to the server:
{
"/api": {
"target": "http://civil-planet-279210.uc.r.appspot.com" ,
"secure": true,
"logLevel": "debug",
"changeOrigin": true,
"pathRewrite": {
"^/api/*": ""
}
}
}
A Similar question was also posted but the user was using Cloud Endpoints while my server is in python flask. I could not use the solution.
Not sure if I should post the app.yaml for the python server as it is working properly.
Your assistance would be greatly appreaciated.
According to my understanding this is working as expected. According to the documentation about header element we may find in url part:
The URL pattern has some differences in behavior when used with the following elements:
static_dir
Uses a URL prefix. The regular express pattern should not
contain groupings when used with the static_dir element. All URLs that
begin with this prefix are handled by this handler, using the portion
of the URL after the prefix as part of the file path.
So calling .../api/landing will use the same logic: " using the portion of the URL after the prefix as part of the file path."
I am not sure what is your intention, but I think you should create the handler for the feature you want to invoke.
BTW you are using Python 2 which is not already not recommended and not supported. I would consider migration. You can see this at top of every page of documentation.
Was able to fix the issue with the following yaml - I was missing the third handler.
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: dist/index.html
upload: dist/index.html
- url: /
static_dir: dist
- url: /.*
script: auto
secure: always
redirect_http_response_code: 301
skip_files:
- e2e/
- node_modules/
- src/
- coverage
- ^(.*/)?\..*$
- ^(.*/)?.*\.json$
- ^(.*/)?.*\.md$
- ^(.*/)?.*\.yaml$
- ^LICENSE

Red Hat Service Mesh: custom header transformed into x-b3-traceId is lost

I am trying to integrate a legacy system with microservice hosted on Red Hat OpenShift platform. The service is a java app behind ingress gateway.
The legacy app passes unique operation identifier as a custom header uniqueId. The microservice leverages openshift service mesh support for Jaeger so I can pass tracing headers such as x-b3-traceid and see the request trace in Jaeger UI. Unfortunately, the legacy app cannot be modified and won't send jaeger headers but uniqueId conforms jaeger rules and seems ok to be used for tracing.
I am trying to transform uniqueId into x-b3-traceid on an envoy filter. The problem is that I can copy it to any other header, but cannot modify x-b3-* headers. Istio keeps generating new set of x-b3-* headers no matter what I do in envoy filter. See filter code below.
I tried different filter positions (on ingress gateway, on pod sidecar, before envoy.router, etc). Seems nothing works. Can anyone recommend how can I pass custom header as a traceId for service mesh's jaeger? I can create a custom proxy service transforming one header with another but it looks redundant. Is it possible to achieve that with service mesh only?
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: call-id-filter
namespace: mynamespace
spec:
filters:
- filterConfig:
inlineCode: |
function envoy_on_request(request_handle)
headers = request_handle:headers()
uniqueId=headers:get("uniqueId")
if (uniqueId ~= nil) then
request_handle:headers():add("x-b3-traceid", uniqueId) -- istio overwrites these values
request_handle:headers():add("x-b3-spanid", "myspan")
request_handle:headers():add("x-b3-sampled", "1")
request_handle:headers():add("my-custom-unique-id", uniqueId) -- works fine
request_handle:logCritical("envoy filter setting x-b3-traceid with"..uniqueId)
end
end
filterName: envoy.lua
filterType: HTTP
insertPosition:
index: FIRST
listenerMatch:
listenerType: GATEWAY
portNumber: 9011
workloadLabels:
app: istio-ingressgateway

In case we need to make two step rest api call using magrite agent? How to go about the same?

I need to make a rest api call using magrite agent, but the challenge is the api call comprises of two steps.
POST call to receive the access token
GET call to use the bearer token and call the query
Let me know if anyone can help.
Assuming you get a new access token each time you want to get the data, the process is:
Call to get the token
Extract the token from the response
Call with the token to get the data
The magritte rest plugin supports this!
Preferred Approach
If you have access to edit the magritte source then there is a better way, you can use an Auth Call Source (magritte-rest-auth-call-source) to automate this process for all syncs. The source will perform steps 1 & 2:
type: magritte-rest-v2
sourceMap:
...
my_new_auth_source:
type: magritte-rest-auth-call-source
url: 'https://my-api.com/'
headers:
Authorization: '{%access_token%}'
authCall:
type: magritte-rest-call
method: GET
saveResponse: false
path: /get/access/token
extractor:
- type: magritte-rest-json-extractor
assign:
access_token: /token/json/path
The call would then look like:
type: rest-source-adapter2
oneFilePerResponse: false
cacheToDisk: false
restCalls:
- type: magritte-rest-call
path: /get/data
method: GET
Alternative
If the data and the token are at different domain names (i.e. requiring different sources), or if you cannot edit the source, then this is an alternative. Keeping any tokens in the source however is preferred, so only use this method if you have to.
You can have multiple calls in a single sync, and state is preserved between the calls, an example might look something like this:
type: rest-source-adapter2
oneFilePerResponse: false
cacheToDisk: false
restCalls:
- type: magritte-rest-call
path: /get/access/token
method: GET
saveResponse: false
extractor:
- type: magritte-rest-json-extractor
assign:
access_token: /token/json/path
- type: magritte-rest-call
path: /get/data
method: GET
saveResponse: true
parameters:
token: '{%access_token%}'
A couple of gotchas & other points with this approach:
saveResponse is true by default (I left it in the second call for clarity), so it needs to be explicitly set to false in the first call to avoid saving your token in the output dataset!
in the event that the data and token are behind different domains (so in different sources) you can add source: my_data/token_source to each call to point them at the right source.
More Detail
More detail can be found in the documentation, open the Foundry docs and search for REST API Plugin to find it.

Using Ansible to list only available NICs from a pool of 10 NICs in Azure

Problem statement:
List only available NICs (not attached to any VM) from a pool of 10 NICs in Azure cloud.
Condition:
Not to use Azure resource tags to get NIC state information (is available or not).
Below code snippet solves the problem using tags which fails to satisfy the above condition.
- hosts: localhost
tasks:
- name: Get available NICs from NIC Pool
azure_rm_networkinterface_facts:
resource_group: '{{NIC_rg_name}}'
tags:
- available:yes
register: NicDetails
- name: List available NICs
debug:
msg: '{{NicDetails.ansible_facts.azure_networkinterfaces}}'
How can I achieve the same result without using Azure ressource tags ?
I believe , below code would return all the network interfaces within a resource group
- name: Get network interfaces within a resource group
azure_rm_networkinterface_facts:
resource_group: Testing
This should do what you are looking for.
Also if we want to use tags , we can use the below code
- name: Get network interfaces by tag
azure_rm_networkinterface_facts:
resource_group: Testing
tags:
- testing
- foo:bar
You can find the common return value details here.
Prerequisite to run the module:
python >= 2.7
azure >= 2.0.0

Netlify: How to create domain alias dynamically on Netlify

currently in Netlify you can create aliases of my custom domain normally, but I would like to know if i can add these alias from an API / Programmatically.
Netlify provides documentation on their api including the following:
UPDATE SITE
PATCH /api/v1/sites/{site_id} will let you update some attributes on a site
PUT /api/v1/sites/{site_id} will let you update some attributes on a site
This lets you update a site. Takes all the same parameters as when
creating a site.
When creating a site, you can set the following properties:
name, the name of the site (mysite.netlify.com)
custom_domain, the custom domain of the site (www.example.com)
password, password protect the site
force_ssl, will force SSL on the site if SSL is enabled
domain_aliases, is an array of OTHER hostnames your site has in addition to the custom domain
processing_settings, lets you set the following processing settings: {“css”: {“bundle”: true, “minify”: true}, “js”: {“bundle”: true, “minify”: true}, “html”: {“pretty_urls”: true, “canonical_urls”: true}, “images”: {“optimize”: true}}
repo, lets you configure continuous deployment. It’s a bit complicated to create a repo object so please contact support for guidance if you want to do this.
Based on this, I suspect you would be able to use their API to adjust your custom domain - however they do not make any reference to a means to adjust aliases such that you can control more than one domain at a time. You may be able to contact their support team and request assistance if that is something you require.