I have three path variables for an API. I want to mask one input on Swagger UI with *****.
How can I do this when using Springdoc OpenAPI?
You just use the swagger annotations:
#Parameter(schema = #Schema(type = "string", format = "password"))
As already shown by jenkinsme in their answer, set the format to password. Also, the type field is not needed as it defaults to string (hopefully all passwords are strings).
#Parameter(schema = #Schema(format = "password"))
The above will show up as shown in the below image
Refer the OpenAPI specification page on Data Types for all the supported types
Related
We have introduced swagger to our existing spring rest application. We already had javax.validation's #NotNull to validate the payload, which was working fine.
After we introduce Swagger 3, we used #Schema(required = true) along with #NotNull. Now the Swagger override's the error message of javax.validation.
Before swagger: "XXX must not be null" which was generated by javax.validation.
After swagger : Missing required creator property 'XXX'.
Is it possible to disable swagger validation?
Thanks in advance
I am trying to add filters to the requests for the GA4 Custom Dimension but getting multiples error.
If I try to send without any filters I am able to get data so no issue with the custom dimension setting.
I am getting confused about the syntax.
referred from - https://googleapis.dev/ruby/google-api-client/v0.53.0/Google/Apis/AnalyticsreportingV4/DimensionFilterClause.html
{
:property=>"properties/1234",
:dimensions=>[{:name=>"date"}, {:name=>"customUser:type"}],
:metrics=>[{:name=>"activeUsers", :invisible=>false}],
:date_ranges=>[{:start_date=>"2023-01-01", :end_date=>"today", :name=>"date"}],
:order_bys=>[{:dimension=>{:dimension_name=>"date"}}],
:dimension_filter_clauses=>[{:dimension_name=>"customUser:type", :expressions=>["Customer"], :not=>false, :operator=>"OR"}],
:keep_empty_rows=>false,
:return_property_quota=>true
}
What should be the correct syntax to make the request?
In Google Analytics 4 (GA4) APIs, you can apply dimension filters to retrieve data for specific dimensions. The GA4 APIs use the filters parameter to filter the data
require "google/apis/analyticsdata_v1alpha"
analyticsdata_service = Google::Apis::AnalyticsdataV1alpha::AnalyticsDataService.new
# request parameters
request = Google::Apis::AnalyticsdataV1alpha::RunRealtimeReportRequest.new(
report_request: Google::Apis::AnalyticsdataV1alpha::ReportRequest.new(
metric_aggregations: ["count"],
dimensions: ["eventName"],
filters: "eventName==ExampleEvent"
)
)
response = analyticsdata_service.run_realtime_report(request)
puts response.to_json
I got the answer after trial and error this will be for v1beta.
{
:property=>"properties/<property_id>",
:dimensions=>[{:name=>"date"}, {:name=>"customUser:type"}],
:metrics=>[{:name=>"activeUsers", :invisible=>false}],
:date_ranges=>[{:start_date=>"2023-01-01", :end_date=>"today", :name=>"date"}],
:order_bys=>[{:dimension=>{:dimension_name=>"date"}}],
:dimension_filter=>{:filter=>{:field_name=>"customUser:type", :string_filter=>{ :match_type=> "EXACT", :value=>"<value>"}}},
:keep_empty_rows=>false,
:return_property_quota=>true
}
I'm having trouble to find the right way to create sentence dictionary using new portal
There is still a way to create one in legacy portal, but no clear examples. Also I'm curious if sentences would take into account grammar. I want to create some translations fron English to Polish which has quite complex grammar and depending on grammatical case and context different output is expected.
We can you the translator dictionary from the new portal too. But we need to take the keys generated from the new portal to custom language translator portal. Let’s walk through the solution.
Part 1: Language translation using Azure portal. Inbuild grammar (not complete)
Go to azure portal and search for a translator
Fill in the details according to the subscription
The above block will convert the English language into Polish according to the requirement. Below is the python code generated for translation. Fill in the details required according to the subscription.
import requests, uuid, json
# Add your key and endpoint
key = "<your-translator-key>"
endpoint = "https://api.cognitive.microsofttranslator.com"
# location, also known as region.
# required if you're using a multi-service or regional (not global) resource. It can be found in the Azure portal on the Keys and Endpoint page.
location = "<YOUR-RESOURCE-LOCATION>"
path = '/translate'
constructed_url = endpoint + path
params = {
'api-version': '3.0',
'from': 'en',
'to': ['fr', 'zu']
}
headers = {
'Ocp-Apim-Subscription-Key': key,
# location required if you're using a multi-service or regional (not global) resource.
'Ocp-Apim-Subscription-Region': location,
'Content-type': 'application/json',
'X-ClientTraceId': str(uuid.uuid4())
}
# You can pass more than one object in body.
body = [{
'text': 'I would really like to drive your car around the block a few times!'
}]
request = requests.post(constructed_url, params=params, headers=headers, json=body)
response = request.json()
print(json.dumps(response, sort_keys=True, ensure_ascii=False, indent=4, separators=(',', ': ')))
Get the keys before going to part 2
Part 2: To add sentence dictionary. Use the custom translator services studio
https://language.cognitive.azure.com/home -> Check into this link
This will create a project where we can choose the language to convert and start the translation with sentence dictionary. By default, sentence dictionary is application in new language translation.
Having a hard time trying to figure out the "right" way of doing this. I'm using Micronaut to create a REST service that uses OpenAPI/Swagger by transforming my API annotations into open API specs. I'm trying to eliminate annotation duplication between APIs that take the same parameters in.
#Operation(
operationId = "...",
summary = "..",
description = "...",
)
#Post(uri = "something/{object_type}")
fun apiA(#Parameter(name = "", description = "") object_type: String) {
}
#Post(uri = "something-else/{object_type}")
// This should have the same #Parameter as the above api but I don't want to copy/paste
fun apiB(object_type: String) {}
I've tried to create my own annotation that has #Parameter on it but it doesn't seem to inherit. I know OpenAPI has a "component" concept but I'm not sure where my particular framework wants me to define components. Any pointers would be greatly appreciated.
I'm having Apache-CXF REST service and using swagger for documentation. Default value for API changes based on environment (dev/qa/prod). I want to externalize the default value (in this case -5247710000779009) to a properties file which i'm already maintaining based on env for different purposes.
#ApiParam(value = "Customer information will be fetched by this account number", required = true, defaultValue = "5247710000779009")
How can i achieve this ?