I work with symfony project and i want to generate documentation for my REST Web Service with swagger 2,so i installed swagger-bundle
and i configurid it.but when i tri to generate the json api documenation with this command
app/console -e=dev swagger:dump
i got this error.
You must call one of in() or append() methods before iterating over a
Finder.
this is my config file
swagger:
version: '2.0'
info:
title: 'My API'
version: '1.0.0'
description: 'My API Description'
host: '127.0.0.1'
base_path: '/v2'
schemes:
- http
produces:
- application/json
consumes:
- application/json
annotations:
bundles:
- BOBundleBundle
any help please.
check if you put the settings in the correct config file (app/config/config_dev.yml)
Related
we are using wso2 API MANAGER 3.0.0, and we have a situation where we want to publish an API whose request body parameter should be an attachment
is it possible to send an attachment in wso2?
Create a new API with the following Swagger file in WSO2 API Manager.
swagger: '2.0'
info:
description: 'Sample'
version: 1.0.5
title: File Upload
host: fileupload.swagger.io
basePath: /v2
paths:
/upload:
post:
summary: upload a file
description: ''
consumes:
- multipart/form-data
parameters:
- in: formData
name: uploadFile
description: Upload file
required: true
type: file
responses:
'200':
description: Valid input
I'm trying to deploy two API versions to Google Cloud Endpoints but end up facing configuration issues during the deployment.
API definition api-1.yaml looks like this:
swagger: "2.0"
info:
description: "API"
title: "API"
version: "1.0.0"
host: "api.endpoints.GCP_PROJECT.cloud.goog"
basePath: "/v1"
x-google-api-name: v1
x-google-endpoints:
- name: "api.endpoints.GCP_PROJECT.cloud.goog"
target: "IP_ADDRESS"
...
This works just fine if deployed alone. However if api-2.yaml is added:
swagger: "2.0"
info:
description: "API"
title: "API"
version: "2.0.0"
host: "api.endpoints.GCP_PROJECT.cloud.goog"
basePath: "/v2"
x-google-api-name: v2
x-google-endpoints:
- name: "api.endpoints.GCP_PROJECT.cloud.goog"
target: "IP_ADDRESS"
...
This leads to deployment error: OpenAPI spec is invalid. Multiple endpoint entries are defined in the extension \'x-google-endpoints\'. At most one entry is allowed.
Removing x-google-endpoints extension from one yaml file works but it leaves another yaml file as incomplete and thus, not optimal solution.
Could there be and issue with combining/validating yaml files during deployment? Can x-google-endpoints extension be used to define .cloud.goog domain for versioned API's?
There are two ways to do this:
1) version is in the domain name, such as v1-api.endpoints.GCP_PROJECT.cloud.goog.
You define and deploy two services; one for v1 and another for v2. Each has its own IP, proper service name and its own backend. This is most straightforward way and easy approach.
2) version is in the path, such as api.endpoints.GCP_PROJECT.cloud.goog/v1. You can only define and deploy one service. But you have two backends. This is tricky one. You can use x-google-backend extension in the OpenApi spec and deploy one Cloud Endpoint service.
You are using two ESP proxy as: v1_esp -> v1, v2_esp -> v2.
Each proxy has its own IP and you are trying to bind a domain name to two IPs. This is not supported.
My suggestion is to use one ESP as such:
esp -> v1 + v2 by using x-google-backend.
With the following:
In the openApi.yaml
paths:
/v1/path1:
...
x-google-backend:
address: v1_host
# do above for all your path/methods
/v2:
...
x-google-backend:
address: v2_host
# do above for all your path/methods
x-google-endpoints:
- name: "api.endpoints.GCP_PROJECT.cloud.goog"
target: "IP_ADDRESS"
add --enable_backend_routing and --rewrite to remove /v1 and /v2 prefix before sending the request to your backends.
We have not tested such deployment, but you can try it.
I encounter an error when I try to deploy a static website to Pivotal Web Services with Concourse CI. I want to push a static website using the static_buildpack. The index.html is placed in the root folder. When I push the code from the command line directly to Pivotal Web Services using the cf push command everything works fine.
When I use the concourse pipeline the build is terminated successfully however I get an error when accessing the website. I get an nginx 403 Forbidden error when trying to access the website. I tried the following manifest with the following pipeline (see below). When using Concourse CI the container is created successfully, the buildpack is used, nginx is installed and the droplet is uploaded. The app itself starts successfully.
The Cloud Foundry Logs show the following error:
2017/09/05 08:42:54 [error] 70#0: *3 directory index of "/home/vcap/app/public/" is forbidden, client: <ip>, server: localhost, request: "GET / HTTP/1.1", host: "agencydemo.cfapps.io"
manifest.yml
---
applications:
- name: agencyDemo
memory: 64M
buildpack: staticfile_buildpack
host: agencyDemo
pipeline.yml
resources:
- name: app_sources
type: git
source:
uri: https://github.com/smichard/CloudFoundryDemo
branch: master
- name: staging_CloudFoundry
type: cf
source:
api: {{pws_api}}
username: {{pws_user}}
password: {{pws_password}}
organization: {{pws_org}}
space: {{pws_space}}
skip_cert_check: false
jobs:
- name: deploy-website
public: true
serial: true
plan:
- get: app_sources
trigger: true
- put: staging_CloudFoundry
params:
manifest: app_sources/manifest.yml
The source code can be found on GitHub
nginx 403 Forbidden happens mainly when index.html is not found. suggested steps
Check your buildpack (which now is updated as buildpacks in manifest file)
check command or dist folder
cf push -p ./dist/ -f manifest-{your_envireonment}.yml --no-start (if your index.html is directly under dist folder )
or
cf push -p ./dist/{your_app_name} -f manifest-{your_envireonment}.yml --no-start (if your index.html is under dist/{your_app_name} folder )
You must ensure that index.html and other angular static files are directly present inside public/ folder and not in something like public/your-app-name/
Another solution is to fix the path-attribute in your manifest.yml as follows:
---
applications:
- name: agencyDemo
memory: 64M
buildpack: staticfile_buildpack
host: agencyDemo
path: ./dist/your-app-name
Docs
I am developing a REST API using dropwizard. The resource can be accessed using https://<host>:port/item/1. As it can be seen there is no URI prefix. If I have to configure a URI prefix what needs to be done. Can it be configured in yaml configuration file?
Thanks!
Yes the URI prefix a.k.a root path can be configured in YAML. You could use the simple server factory configuration. It's simple, add these two lines in your YAML. I've used 'api' as the prefix. You can replace it with the URI prefix you want.
server:
rootPath: '/api/*'
A slightly more elaborate server configuration looks something like this,
server:
adminConnectors:
-
port: 18001
type: http
adminContextPath: /admin
applicationConnectors:
-
port: 18000
type: http
rootPath: /api/*
type: default
You can refer to this example https://github.com/dropwizard/dropwizard/blob/master/dropwizard-example/example.yml for server and other configuration details.
It's also a good idea to go through this if you are just getting started with dropwizard http://www.dropwizard.io/0.9.2/docs/getting-started.html
I was following a blog post (link no longer available) and added memcached to services.yml
parameters:
memcached.servers:
- { host: 127.0.0.1, port: 11211 }
services:
memcached:
class: Memcached
calls:
- [ addServers, [ %memcached.servers% ]]
Then in my controller:
$memcached = $this->get('memcached');
Looks very pretty. If I can get past 500 - You have requested a non-existent service "memcached"!
The test code from php connects to memcached without any troubles. Done cache:clear, cleared cache manually - doesn't help.
Where should I look?
Adrien was right in his comments - services.yml file isn't used by default. You have to explicitly include it in config.yml