Swagger UI not working with Swashbuckle latest version - azure

I am using Swashbuckle 5.3 version in my .NET Web API with Basic Authentication (as per this link). Now when I am trying to update with Swashbuckle 5.6 version, it's throwing error 'Key is not found'.
The issue is at following code snippet. During route mapping, it's not able to find 'swagger_ui' from route collections. I tried with other different route values ( like 'swagger' , '/swagger','swagger/docs' ) but none of them is working
var route = config.Routes["swagger_ui"];
config.Routes.Remove("swagger_ui");
config.Routes.MapHttpRoute("swagger_ui", route.RouteTemplate, route.Defaults, route.Constraints, new AuthMessageHandler(route.Handler));

I replaced 'swagger_ui' with 'swagger_ui_shortcut' and it works :) I did change by referring this [link] (https://github.com/domaindrivendev/Swashbuckle/blob/master/Swashbuckle.Core/Application/HttpConfigurationExtensions.cs)
But I will investigate for proper solution

Related

Broadleaf - running locally - problem getting started the API project

I'm trying to run Heat Clinic 6.0.1 locally following getting started tutorial: https://www.broadleafcommerce.com/docs/core/current/getting-started/running-locally
I managed to run admin and site but not the API project. The application starts without problems but when I go to http://localhost:8082/api/v1/swagger-ui.html I get a 404. In the log I see this exception:
javax.servlet.ServletException: Circular view path [error]: would dispatch back to the current handler URL [/error] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
Also trying to log in directly in the API with user broadleafapi and password gives 404.
My environment: Windows 10, jdk 8, maven 3.6
What's wrong? Can you help me? Thank you
Thanks for the report. I reproduced this and it looks like that with the update to Spring Boot 2.0, we did not appropriately override the updated property that specifies the servlet location to embedded Tomcat. Thus, when you went to /api/v1/swagger-ui.html, the application treats it exactly like that URL which is what gave the 404.
Setting the server.servlet.contextPath=/api/v1 property appropriately stripped off this path as part of the servlet context and resolved the 404.
I tested around a bit and was able to 'Authorize' the app (button at the top right of the Swagger page) with the credentials information that get spit out in the logs:
Basic auth configured with user broadleafapi and password: <<generated>>
then I was able to hit the API endpoints.
The changes you will need to make locally in your project to consume the fix are at https://github.com/BroadleafCommerce/DemoSite/commit/422d1cdc37f847afd8bec0be477ab784cbad2e9d#diff-991c59b6dbb0f619b8570d8f8779eaddR11. You will notice that I moved the original definition in default.properties over to common.properties and I recommend that you do the same. To be clear, follow these steps:
Delete the server.servlet.contextPath entry in `api/src/main/resources/runtime-properties/default.properties
Change server.servletPath in api/src/main/resources/runtime-properties/common.properties to server.servlet.contextPath
Thanks for trying out Broadleaf and the report, sorry for the rough early start!

Facebook Graph API version not supported

I want to access a facebook page data, and my fb Graph API version is 3.1, when i am writting this(in python):
graph = facebook.GraphAPI(access_token=token, version = 3.1)
it gives a version error, i.e:
facebook.GraphAPIError: Valid API versions are '2.7', '2.8', '2.9', '2.10', '2.11', '2.12', '3.0'
how can i access facebook Graph API through my version in python.
Thanks in advance.
You will either
have to use an app id that still allows you to use a lower API version, or
wait for an update of the library, or
see where the library does this check and manually add 3.1 to the list there.
If you are using this library https://github.com/mobolic/facebook-sdk/, you can edit the __init__.py file, which currently contains the following line:
VALID_API_VERSIONS = ["2.7", "2.8", "2.9", "2.10", "2.11", "2.12", "3.0"]
If you add "3.1" to that list, you should be able to use API version 3.1 without getting this error.

Integrating Aurelia in existing MVC Application

I have an application in MVC 4.5 using VS 2015.
To this existing application, a new module has to be developed and what I'm trying is to develop this using Aurelia framework.I had fair bit of experience in aurelia framework.Hence I want to integrate our existing MVC application with Aurelia but unable to achieve this while routing.Hence posting this here in this platform.
These are the links that I went through for this purpose :
- Link1
- Link2
- Link3
- Link4
- Link5
To some extent I'm able to achieve this.From my partial view when the request is sent to main.js setRoot to app.html, this routes to app.js, but any kind of code written there results in Invalid Token Syntax error even if I write just one line of code in app.js.
Also, trying to set route in app.js results in route not found error :
This is what I tried:
Created an standalone aurelia app, wrote code in app.ts and was able
to render grid chart in corresponding html(app.html).
Created an MVC application(followed one of the above link) by adding one view , then routing to app.js through main and was able to render the page.
Also, I tried with normal routing like this in app.js.It resulted in error as cant find route.
What I'm ultimately trying to achieve is , when I click on any sub-tab(as I've Tab/Sub-tab views) and my partial view(cshtml) gets rendered, it should route to the aurelia app and render the content in that particular section with result.
Is this feasible or am I missing something here?? Any help would be highly appreciated..

Python2 connexion framework - controller in directory structure

I am playing around with using the connexion framework to setup a REST API access for my application.
My application is is built on python2, I installed the connexion framework for python2 and played around with the yaml file via the editor (editor.swagger.io). I downloaded the Python Flask server code, converted it to be compatable with Python2 and tested for a single controller.
When the controller is placed in the same directory as the place where the server is run. Everything was fine - all routes were added and working as expected. I then proceeded to split the controller based on some business logic and wanted a tree structure for each controller.
Something like
myapp/api/magic1/magic1_controller.py
myapp/api/magic2/magic2_controller.py
and so on.
This does not work for python2. It seems to work for python3. Any ideas why?
I get the following error from logs
DEBUG:connexion.api:Security Definitions: {}
DEBUG:connexion.api:Validate Responses: False
DEBUG:connexion.api:Creating API blueprint: /api
DEBUG:connexion.api:Adding swagger.json: /api/swagger.json
DEBUG:connexion.api:Adding swagger-ui: /api/ui/
DEBUG:connexion.api:Adding /api/magic1/{name}...
ERROR:connexion.api:Failed to add operation for GET /api/magic1/{name}
In the yaml config file I add the OperationId as api.magic1.func1() and so on.
Following the information you provided here the operationId should be set to api.magic1.magic1_controller.func1 and not api.magic1.magic1.func1().
You are missing to provide more details about your problem. Code snippets would help to guide you in a more detailed solution.

Foxx oauth2 configuration

To play with the demo-sessions app, I've got the oauth2 app mounted on /oauth2 as required.
In arangodb/Foxx doc, the oauth2 endpoints seems to be defined as strings (i.e https://github.com/arangodb-foxx/util-oauth2 )
But when I perform that with correct urls, and try to play with oauth, I've got an error :
...\oauth2\APP\manifest.json\": attribute child \"authEndpoint\" fails because [\"authEndpoint\" must be an object] (was \"[object Object]\").]","...
Oauth endpoints definitions are expected to be objects, not strings.
So what is the correct configuration for Foxx oauth2 ?
Thanks for help,
I can't reproduce your problem but the OAuth2 app has been updated for ArangoDB 2.7. You can still install odler versions of the OAuth2 app from the "install from GitHub" dialog, though.
I understand my mistake. In the code of the oauth2 2.0 release, the manifest just references the export.js file. In the previous release (1.2), a providers.js file was supplied and referenced in the manifest. Then in this previous release, it was possible to use different providers (what I want) as described in the 1.2 setup.js.
var providers = db._collection(providersName);
I just fetch the files providers.js, and setup.js from 1.2 github tag and configure them for my configuration, and that's ok.

Resources