Add swagger to phoenix framework application - swagger

I am new to Elixir/Phoenix. Is there a way to add Swagger documentation to the Phoenix api project?
I looked at https://github.com/xerions/phoenix_swagger but that was updated several months ago and has unresolved old open issues.
This is another one https://github.com/OpenAperture/swaggerdoc with similar issues.
Or should I be using Maru for api projects?

Both projects get updates. SwaggerDoc offers Ecto support, but the Build status has been failing for two months.
PhoenixSwagger doesn't, but depends on extending the controller (which you can use to implement Ecto support yourself). Also it appears to be actively maintained at the moment.

We are actively maintaining https://github.com/everydayhero/phoenix_swagger with additional features
defmodule MyApp.UserController do
use MyApp.Web, :controller
import PhoenixSwagger
swagger_path :index do
get "/users"
summary "Get users"
description "Get all users"
response 200, "Success", :Users
tag "users"
end

Related

Plugin.InAppBilling always returns "Invalid Product" on Xamarin.iOS

I have been trying to implement the Plugin.InAppBilling NuGet package for the last weeks and trying to run the "Get Product Details" example from the documentation page.
However, the line
var items = await billing.GetProductInfoAsync(ItemType.InAppPurchase, productIds);
always throws the "PurchaseError.InvalidProduct" Exception.
I am quite sure that everything is set up correctly within AppStoreConnect and that I have followed the documentation exactly.
I am trying to implement this for a MonoGame application, which uses Xamarin to host the app, which is why I am using the recommended Version "5.3.2-beta" of the InAppBilling-Plugin.
Is this a common error or are there any known workarounds?
Best Regards,
Dokug
Plugin.InAppBilling Version 5.3.3-beta resolved this problem.

PHPUnit: 404 code on every request

I have project A and project B in my vagrant machine. Both working and accessible via http://a.local/ and http//b.local/ . These are Apigility APIs.
I am now writing tests with PHPUnit.
I want to test that project A can call services on project B and check that:
Response code is 200.
Response is JSON.
etc...
PHPUnit keeps on failing because the response is 404 when calling any service (from a to b or from b to a):
{404 => string(54) "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
'title' =>
string(9) "Not Found"
'status' =>
int(404)
'detail' =>
string(15) "Page not found."}
All URLs are accesible via browser.
All URLs are accesible via Curl.
Browser and Curl return the same (identical) responses and http codes.
/etc/hosts file is properly configured.
PHP.ini file are identical for cli and fmp.
Any ideas what am I doing wrong? Thanks!
php-unit is probably more suitable for testing smaller parts of your application (unit testing). You can also do Curl tests of course but there are probably much better solutions (REST testing solutions/frameworks) to do this.
If you want to test your full application using Curl, you have to make sure that your php-unit bootstrap loads all the application dependencies.
It would also be a good idea to write a abstract wrapper or a test case specifically for testing your rest-api with Curl requests so you don't have to repeat too much code. Check this answer on stackoverflow to get an idea on how you could do this. But I bet there are a lot more examples available online and maybe you should do some googling.
You don't have ZF\Rest installed. The abstract factory to create rest resources, including doctrine controllers, is in that module.

Setting Jira Projects Type, Workflow and Screens Scheme Via API

I am running JIRA 6.1 and I'm trying to use the API to create a new project. Since JIRA 6.1's Rest API doesn't support creating a project I'm using the Soap API.
Note I'm doing this using the Atlassian .net SDK, but I imagine the solution is irrelevant to that.
I have managed to create the project no problem, but I am now trying to set the following schemes in the project
Issue Type
Workflow
Screens
As far as I can tell the 6.1 Soap API (and the 7 Rest API) doesn't actually allow you to modify these schemes, only allowing you to set the Permission, Security and Notification schemes - https://docs.atlassian.com/jira/REST/latest/#api/2/project-createProject
Is that the case or am I missing something?
If it is possible to set the scheme's I want, does anyone have any examples I could base my work off?
Thanks
Got an answer from Atlassian support, and as I suspected this isn't possible.
No, you're correct, the SOAP and REST APIs do not have those
functions.
You're going to need to write type-2 add-ons to provide the functions
you need if you're going to do this remotely, but with the caveat that
if you're willing to do that, you will probably find it a lot easier
to simply write add-ons that do all the work instead of just providing
the external hooks. (Let's put it this way - I was able to code
post-functions to create an entire customised project for JIRA 4 in a
couple of days. Versus a week to add a single SOAP call for feeding
back some simple user data)
I won't mutter too much about using SOAP - I'm assuming you know it's
dead, gone and mostly pointless to code for
Of course, there is the CLI plug-in which I think I'd be silly to ignore
JIRA Command Line Interface (CLI) support this for 6.1 through 7.0
including setting schemes that are not supported by SOAP or REST
except for screens. See the createProject action for details of what
is supported.
Starting from Jira 7.0.0, we can use Create project REST API [POST /rest/api/2/project]
which also allows setting following schemes while creating the project,
issueSecurityScheme
permissionScheme
notificationScheme
workflowSchemeId
Sample Request Payload:
{
"key": "EX",
"name": "Example",
"projectTypeKey": "business",
"projectTemplateKey": "com.atlassian.jira-core-project-templates:jira-core-project-management",
"description": "Example Project description",
"lead": "Charlie",
"url": "http://atlassian.com",
"assigneeType": "PROJECT_LEAD",
"avatarId": 10200,
"issueSecurityScheme": 10001,
"permissionScheme": 10011,
"notificationScheme": 10021,
"workflowSchemeId": 10031,
"categoryId": 10120
}
For issuetype and screen schemes, there is no such parameter available which can be set using the above create project rest api.
You can also try to use the following Rest endpoint to create jira project using shared configuration which will allow you to reuse all schemes which are present in the template project.
/rest/project-templates/1.0/createshared/{{projectid}}
More information on the Jira rest API can be found at https://docs.atlassian.com/software/jira/docs/api/REST/8.9.0/#api/2/project-createProject
You can try the following curl request for creating jira project
curl -D- \
-u admin:sphere \
-X POST \
-H "X-Atlassian-Token: nocheck" \
-H "Content-Type: application/x-www-form-urlencoded" \
"http://localhost:port/rest/project-templates/1.0/templates?projectTemplateWebItemKey=com.atlassian.jira-legacy-project-templates%3Ajira-blank-item&projectTemplateModuleKey=com.atlassian.jira-legacy-project-templates%3Ajira-blank-item&name=SECOND+Create+from+REST+API&key=CFRAPI&lead=admin&keyEdited=false"

Routing in Symfony 1.4: Is there a way to allow sf_method = OPTIONS for preflight HTTP requests

you all might know that browsers do preflighted HTTP requests in some cases:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Preflighted_requests
My web application is still on Symfony1. I want to implement a RESTful service and therefore using Symfony routing to allow specific HTTP request methods like GET or POST (http://symfony.com/legacy/doc/reference/1_4/en/10-Routing#chapter_10_sub_sf_method).
Example:
login:
url: /v1/login
class: sfRequestRoute
param: { module: rest, action: login }
requirements:
sf_method: [post, put, delete]
#sf_method: [options] NOT WORKING
It seems to me that OPTIONS requests cannot be defined/handled as sf_method value. Because I couldn't find any information if my idea is right, I'm wondering if I'm right or maybe there is a solution I couldn't find, too.
Thanks in advance!
Sorry to revive this old question but I found a solution. I ran into the same issue and I added the request method OPTIONS to the allowed methods in lib/sfRequest.class.php and lib/sfWebRequest.class.php You can check the latest commit here to see the differences: 6ad018c
Since I cannot update the original Symfony1 GitHub repository, I created a copy with additional fixes needed due to the various PHP upgrades. This fixes the PHP deprecated warnings due to use of the /e modifier in preg_replace calls as well.
Note that this still doesn't make Symfony1 PHP7 compatible. I'm running this successfully with PHP 5.6.30
The repository is https://github.com/diem-project/symfony.git
Background: Diem uses Symfony1 (1.4.20), hence the GitHub organisation diem-project

Asana API retrieve project owner, status and deadline

Is there a way using the Asana api to retrieve the project owner, project status, project description and project deadline?
I checked the API docs and could not find anything, so I am assuming the answer is no (but confirmation is much appreciated).
https://asana.com/developers/api-reference/projects#sections
If there is not a way of doing this via the API, does anyone have any hacks on how to do this using something like Selenium or another tool?
Much appreciated.
Project overview attributes are accessible attributes on project objects in the API.
current_status is the latest status update for the project including the color and text associated.
owner the current project owner.
due_date the current project due date.

Resources