This question already has an answer here:
How to make tokenUrl configurable
(1 answer)
Closed 9 months ago.
This is what I want to do:
"components": {
"securitySchemes": {
"azure_auth": {
"type": "oauth2",
"description": "Azure Active Directory OAuth2 Flow.",
"flows": {
"clientCredentials": {
"tokenUrl": "https://login.windows.net/{tenant}/oauth2/token",
"scopes": {}
}
},
"variables": {
"tenant":"tenantId"
}
}
}
},
I understand that there is no place for variables in the securitySchemes but was wondering if anyone knew a similar solution. If not, I was considering editing the servers property in my spec, something similar to this
Darn, unfortunately this looks like an issue that is posted on the OpenAPI github repo.
Related
I have my API documented and versioned previously using Swashbuckle.AspNetCore, Microsoft.AspNetCore.Mvc.Api.Analyzers, Microsoft.AspNetCore.Mvc.Versioning and Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer.
Everything was fine but all of a sudden today I noticed that JsonPatchDocument Not getting displayed properly in my swagger. I couldn't figure out what's the root cause. But I suspect some Nuget Package Upgrade?
Previously I remember the JsonPatchDocument in my swagger as something similar below:
{
"Operations": [
{
"value": {},
"path": "string",
"op": "string",
"from": "string"
}
]
}
But now it shows something else,
{
"ContractResolver": {}
}
Please assist on what I'm missing
Make sure you are added the AddNewtonsoftJson in program.cs after install the Microsoft.AspNetCore.Mvc.NewtonsofJson
should be like this :
builder.Services.AddControllers().AddNewtonsoftJson();
I followed this tutorial to create local proxy using node.js library. I got rid of the CORS problem, but I have another problem and it is this one:
I suspect that the problem is caused by defining the data source's uri like this:
"dataSources": {
"Z_ATTENDANCE_SRV": {
"uri": "localhost:8081/http://<address>:<port>/sap/opu/odata/SAP/Z_ATTENDANCE_SRV",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/Z_ATTENDANCE_SRV/metadata.xml"
}
}
}
I think the problem is cause by "localhost:8081/" prefix in the URI, but I do not know how to get rid of the problem.
Do you have any suggestions?
The solution to this problem is to set port from which the app runs. I run the app in personal WebIDE so my port in 'proxy.js' file is '58513'. Also it is necessary to add 'http://' as a prefix to the data source uri. So my manifest looks like this:
"dataSources": {
"Z_ATTENDANCE_SRV": {
"uri": "http://localhost:58513/http://<address>:<port>/sap/opu/odata/SAP/Z_ATTENDANCE_SRV",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/Z_ATTENDANCE_SRV/metadata.xml"
}
}
}
However, I am now getting this error which I am not able to resolve.
This looks like an authentication problem. Did you try to add user and password in the request?
"uri": "http://localhost:58513/http://user:password#your.server:8080/sap/opu/odata/SAP/Z_ATTENDANCE_SRV"
I'm trying to add a custom analyzer to elasticsearch via grails plugin. I was able to change the used analyzer to a common analyzer using "searchable" on the domain:
static searchable = {
all = [analyzer: 'snowball']
}
but cannot get it to know a costum analyzer. It is unclear how to translate the following json in the REST API to a groovy closue:
PUT /my_index
{
"settings": {
"analysis": {
"filter": {
"my_synonym_filter": {
"type": "synonym",
"synonyms": [
"british,english",
"queen,monarch"
]
}
},
"analyzer": {
"my_synonyms": {
"tokenizer": "standard",
"filter": [
"lowercase",
"my_synonym_filter"
]
}
}
}
}
}
this question seems to have the same problem but the answer doesn't work, and this answer suggests that it might not be possible, but that doesn't seem reasonable because setting a custom analyzer is pretty basic.
Any suggestions?
There are two ways I see which would help you achieve that.
The first way is by going through the low level API using the injected elasticSearchHelper and accessing ES client directly.
elasticSearchHelper.withElasticSearch { client ->
// Do some stuff with the ElasticSearch client
client.admin()
.indices()
.prepareCreate(indexName)
.setSettings(settings) <--- your settings/analyzers go here
.execute()
.actionGet()
}
A second way involves using an undocumented feature of the ElasticSearchAdminService service, namely the createIndex() method, which allows you to pass in the settings and analyzers you need when creating a new index. The latter basically does exactly the same as the first option above, but you get to use the Grails service directly.
In my content blocker, is there a way to prevent ad-blocking on a certain website? For example, if I want to block ads on all websites besides The Verge, is there a way to prevent the blocking rules I provided from affecting this page?
The above answer is unfortunately incorrect for two reasons, the url-filter attribute is required in the trigger and the if-domain attribute must be an array of domain(s), not a single value. After a lot of trial and error I have found a working solution to whitelist a website.
{
"trigger": {
"url-filter": ".*",
"if-domain": ["the verge.com"]
},
"action": {
"type": "ignore-previous-rules"
}
}
The only documentation I was able to find on what was causing various errors using the above answer was scouring the source code here: https://github.com/WebKit/webkit/tree/67985c34ffc405f69995e8a35f9c38618625c403/Source/WebCore/contentextensions
this article tells the solution http://comments.gmane.org/gmane.os.opendarwin.webkit.user/3971
{
"action": {
"type": "ignore-previous-rules"
},
"trigger": {
"url-filter": ".*",
"if-domain": ["*apple.com"]
}
}
I think you would do something like this.
"action": {
"type": “ignore-previous-rules”
},
"trigger": {
“if-domain”: “theverge.com”
}
Some good links to check out.
Safari Extensibility: Content Blocking and Shared Links
Safari Content Blocking in iOS 9: a tutorial by example
I have three type of documents:
Question
User - contains a source field
Answer - contains the corresponding question ID and user ID
Each questions is answered by multiple users and each user answers each question only once. I want to find for every question how many answers are there answered by users of source "source1".
I think that the nearer that you can arrive to what you want is the following (using Linked documents).
Suppose you have
{ "_id": "user1", "source": "source1" },
{ "_id": "user2", "source": "source2" },
{ "_id": "answer1", "question": "question1", "user": "user1" },
{ "_id": "answer2", "question": "question1", "user": "user2" }
and you define the following view
function(doc) {
if (doc.question) {
emit(doc.question, {_id: doc.user});
}
}
Then if you query that view with key="question1" and with include_docs=true
it will show you all the answers to question1 with all the user information, and you will only have to select those with source = "source1".
For example, with the previous values it will return:
{"total_rows":2,"offset":0,"rows":[
{"id":"answer1","key":"question1","value":{"_id":"user1"},"doc":{"_id":"user1","_rev":"1-c99dc8987841c25c72081a84252793a0","source":"source1"}},
{"id":"answer2","key":"question1","value":{"_id":"user2"},"doc":{"_id":"user2","_rev":"1-0d44e9f4d3806fb932b1b4fcb1e1507b","source":"source2"}}
]}
But AFAIK, what you cannot do in the map function of a view is to use information from other documents.
you can't achieve this within couchdb and need to use thirt-party modules.
for example that one:
sites.google.com/site/nosqldatajoiner/
or google nosql datajoiner