I have used http://editor.swagger.io to produce swagger.yaml for my web.api application (node js). But I was confused when I saw the swagger with my methods. Button Authorize was hidden. But in editor it was shown and works.
The Difference is so:
In Editor everything is all right:
But when I insert same swagger.yaml in my application, Launch browser then I saw the diffrerent view:
You are using a very old version of Swagger UI (2.0?), whereas the Swagger Editor uses UI 3.x.
In UI 2.x, you can enter the API key in the text box in the header:
Note that UI 2.x is no longer maintained by developers. Consider using the latest version of Swagger UI instead.
I had the same problem. Unfornulately I don't remember the exact solution.
But I remember, it had something todo with a bug (in swaggerui) and security-definitions (type=basic must be present to show the button or something...).
This is from my swagger.json (and Auth-Button is shown):
<!-- snip -->
"/xx/xxx/xxx" : {
"post" : {
"responses" : {... },
"security" : [ {
"demouser" : [ ]
}, {
"api_key" : [ ]
} ]
}
}
<!-- snip -->
"securityDefinitions" : {
"api_key" : {
"type" : "apiKey",
"name" : "api_key",
"in" : "header"
},
"demouser" : {
"type" : "basic"
}
}
Edit Info:
You should also take a look at OpenAPI (swagger 3.0?!). It has much cleaner Specification and API! (swaggerui also supports OpenAPI/Swagger3!)
Related
I am trying to create a JSON that will be parsed with OpenApi 2.0 swagger definition in Microsoft Power Automate Custom connector.
This is the JSON i have currently
"connectionParameters" : {
"param1" : "value1",
"param2" : "value2"
}
I want to provide an alternative connection parameter schema, in which user has the option to choose from a set of params to provide value. This can be achieved in OpenAPI 3.0 in the following way:
"connectionParameters" : {
anyOf : [
{
"param1" : "value1",
"param2" : "value2"
},
{
"alternateparam1" : "value1",
"alternateparam2" : "value2"
}
]
}
How can this be achieved in OpenAPI 2.0? "anyOf" is not available in OpenAPI 2.0 definition. I have explored the "discriminator" construct but couldn't find any implementation that I can provide with my JSON schema.
Personally, I think the approach you're trying with v3.0 would be a little confusing for the end user as I don't really understand what they'd actually be selecting in a dropdown persay.
I think your best bet (given you're limited anyway) is to use the ENUM keyword to define a basic list of values that when selected and passed into your API, you do the work in the background to select the more advanced objects that you've listed in your question.
https://swagger.io/docs/specification/data-models/enums/
I implemented with Graph API several calls to create a document set.
I followed the answer posted here concerning the possibility of creating a DocumentSet in SharePoint here : Is it possible to create a project documentset using graph API?
For this i followed those steps :
1. Getting the library driveId :
`GET https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${listId}?$expand=drive`
2. Creating the folder:
POST https://graph.microsoft.com/v1.0/drives/${driveId}/root/children
I have to pass an object:
{
"name": ${nameOfTheFolder},
"folder": {},
}
3. Getting the Sharepoint itemId:
4. Updating the document library:
`PATCH https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${listId}/items/${sharepointIds.listItemId}`
and passing a body:
{
"contentType": {
"id": "content-type-id-of-the-document-set"
},
"fields": {
//whatever fields you want to set
}
}
I have questions concerning the folder creation and the updating:
What is expected in the folder object ?
{
"name": ${nameOfTheFolder},
"folder": {},
}
Concerning the path step:
{
"contentType": {
"id": "content-type-id-of-the-document-set"
},
"fields": {
//whatever fields you want to set
}
}
I have several questions :
Let's consider i have a document type called invoices. Which id is expected for document type id ?
finally how do i pass the fields ? let's say i want to pass 3 fields : invoiceId, claimId, clientId.
Graph API is great but some more information would be helpful. thanks !
I have questions concerning the folder creation and the updating: What is expected in the folder object ?
The folder object (sent as {}) is there to tell graph API that you are creating a folder and not a file. It is a property of the drive item
Let's consider i have a document type called invoices. Which id is expected for document type id ?
This is the id contentType subfield of the list item you are patching
ally how do i pass the fields ? let's say i want to pass 3 fields : invoiceId, claimId, clientId.
You just pass them with repective values like below. See Update listItem
{
"invoiceId": "value",
"claimId": "value"
...
}
One point I didn't express correctly was to know what id is expected here :
{
"contentType": {
"id": "content-type-id-of-the-document-set"
},
"fields": {
//whatever fields you want to set
}
}
I retrieved the different content types of my site by calling this kind of URL and check if the content type exists.
https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${listId}/contentTypes
From the result i retrieve in a Value object the id.
The id looks like this :
0x0120D5200082903AB771604546844DB2AC483D905B00E58445A7D..........
In modern SharePoint, you can also get the Content Type ID from the UI by browsing to SharePoint Site > Site Settings > Site content types > <ContentTypeName> > Content Type ID.
Content Type ID
Not sure if this is easier than via graph, but it's another option at least.
My website is buymobile.I already implement this code, our website made by opencart cms. Many time we try this code but show below error.
domain name (All values provided for https://search.google.com/structured-data/testing-tool/ must have the same domain.)
please help me
<script type="application/ld+json">
{ "#context" : "http://schema.org",
"#type" : "Organization",
"name": "buymobile.com.bd",
"url" : "https://buymobile.com.bd/",
"contactPoint" : [
{ "#type" : "ContactPoint",
"telephone" : "+880171++++++",
"email": "info#buymobile.com.bd",
"contactType" : "customer service",
"contactType" : "technical support",
"availableLanguage" : ["English","Bengali"],
"contactOption" : [],
"areaServed" : "Bangladesh"
} ] } </script>
Surely this error look like (All values provided for https://search.google.com/structured-data/testing-tool/ must have the same domain.) this. Actually tried a lot to solve this error in different ways. According to the Webmaster Central Help Forum this actually a bug of structure data testing tool.It's not an error you can go for it.
While using swagger-editor I create the below YAML that shows an example of the response object. It's properly displaying in the swagger-editor. When I then download the JSON and display it in swagger-ui, the example is completely missing.
/person/{email}/create:
post:
summary: Create a new account
tags:
- Person
parameters:
...
responses:
201:
description: The new SQL ident and sport details
examples:
application/json: |
[
12,
[
{
"sql_idnet" : 12,
"name" : "Basketball"
},
{
"sql_ident" : 13,
"name" : "Ice Hockey"
}
]
]
This might be because the response does not have a schema - in Swagger this means the response does not have a body.
That said, Swagger UI 3.0 displays this example correctly.
Swagger UI and Swagger Editor currently do not support multiple examples. You can follow this issue for updates.
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.