isabinin / aws-apigateway-swagger-exporter Goto Github PK
View Code? Open in Web Editor NEWTool for exporting API specification from existing AWS API Gateway APIs in a Swagger fromat
License: Apache License 2.0
Tool for exporting API specification from existing AWS API Gateway APIs in a Swagger fromat
License: Apache License 2.0
Is this expected or is there anything I should add when running the command?
The following model JSON schema fails to render correctly. It appears as if the exporting fails to render the sub 'meta' objects properties.
Model Template:
{
"$schema" : "http://json-schema.org/draft-04/schema#",
"title" : "Error Schema",
"type" : "object",
"properties" : {
"meta" : {
"type" : "object",
"properties" : {
"code" : { "type" : "integer" },
"message" : { "type" : "string" },
"type" : { "type" : "string" }
}
},
"data" : { "type" : "string" }
}
}
YAML Output:
definitions:
Error:
type: "object"
properties:
meta:
type: "object"
data:
type: "string"
description: "This is a default error schema model"
It looks like the api keys and their related information in APIs & API stages are NOT exported. Not sure if the importer tool supports these, but I'm wondering if you have any plan for these.
$ sh aws-api-export.sh --api APIName
2017-06-01 09:02:59,056 ERROR - Error exporting API in Swagger format
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.JavaType.isReferenceType()Z
at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findDefaultDeserializer(BasicDeserializerFactory.java:1529)
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.findStdDeserializer(BeanDeserializerFactory.java:167)
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:132)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:403)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:352)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:461)
at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:3838)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3732)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2679)
at com.amazonaws.internal.config.InternalConfig.loadfrom(InternalConfig.java:236)
at com.amazonaws.internal.config.InternalConfig.load(InternalConfig.java:249)
at com.amazonaws.internal.config.InternalConfig$Factory.<clinit>(InternalConfig.java:304)
at com.amazonaws.util.VersionInfoUtils.userAgent(VersionInfoUtils.java:142)
at com.amazonaws.util.VersionInfoUtils.initializeUserAgent(VersionInfoUtils.java:137)
at com.amazonaws.util.VersionInfoUtils.getUserAgent(VersionInfoUtils.java:100)
at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:65)
at com.bytecodestudio.apigexporter.APIGExporter.export(APIGExporter.java:89)
at com.bytecodestudio.apigexporter.APIGExporterMain.execute(APIGExporterMain.java:74)
at com.bytecodestudio.apigexporter.APIGExporterMain.main(APIGExporterMain.java:41)
I tried to run the export command after exporting the aws keys in env variables, but it seems to still get the keys from the credential file. Is it expected? And if so, any plan to support the env variables?
And also the region value.
How do i export all the API in one go ?
Using a head build, I exported an API with
basePath: "/"
...
paths:
/service/{foo-id}
...
/session
...
and all the paths were truncated by 3 chars. Perhaps a coincidence they were the 3 chars which were shared across all paths, i.e "/se"
The result became:
basePath: "/se"
...
paths:
rivice/{foo-id}
...
ssion/
I imported into API Gateway a Swagger definition using your importer tool.
A small snippet of a path ๐
paths:
'/service/{cluster-id}':
parameters:
- name: 'cluster-id'
in: path
type: string
format: uint64
required: true
description: The ID of the cluster as an unsigned long decimal string
post:
tags:
- service
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
required: true
schema:
$ref: '#/definitions/registerServiceRequest'
responses:
'200':
description: Success
schema:
$ref: '#/definitions/registerServiceResponse'
'406':
description: Error 406
When its exported using either the AWS Export GUI or your tool the path parameter definitions are gone. I realize there is no direct equivalent in API Gateway (except the Path mapping for HTTP integrations), and there is no schema for them. But I was hoping that an import then export might round trip well enough to be usable.
As it is now paths with /{param} but no parameters declarations dont parse in swagger.
I tried using global parameter defs, path and operation parameters and none show up in the output.
example:
( Note a truncated path -- I will file a separate issue)
paths:
rvice/{foo-id}:
post:
parameters:
- in: "body"
name: "body"
description: "registerFooRequest"
required: false
schema:
type: "object"
required:
- "app-token"
- "timestamp"
properties:
app-token:
type: "string"
description: "A valid service application token"
timestamp:
type: "string"
format: "date-time"
description: "The request timestamp"
responses:
200:
description: "registerFooResponse"
schema:
$ref: "#/definitions/registerFooResponse"
406: {}
x-amazon-apigateway-auth:
type: "NONE"
Throwing a NullPointerException.
Exception:
$ ./aws-api-export.sh --api XXXXXX
2015-12-09 20:02:38,748 ERROR - Error exporting API in Swagger format
java.lang.NullPointerException
at com.bytecodestudio.apigexporter.APIGExporter.getResponseHeaders(APIGExporter.java:274)
at com.bytecodestudio.apigexporter.APIGExporter.export(APIGExporter.java:141)
at com.bytecodestudio.apigexporter.APIGExporterMain.execute(APIGExporterMain.java:59)
at com.bytecodestudio.apigexporter.APIGExporterMain.main(APIGExporterMain.java:34)
Env:
$ java -version
java version "1.7.0_91"
OpenJDK Runtime Environment (IcedTea 2.6.3) (7u91-2.6.3-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)
$ aws --version
aws-cli/1.9.12 Python/2.7.6 Linux/3.16.0-46-generic botocore/1.3.12
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS"
$ uname -a
Linux ****** 3.16.0-46-generic #62~14.04.1-Ubuntu SMP Tue Aug 11 16:27:16 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.