Skip to content

Commit

Permalink
Merge pull request argoproj#3 from JazminGonzalez-Rivero/add-swagger
Browse files Browse the repository at this point in the history
Add ref cleanup for swagger combined
  • Loading branch information
merenbach authored Jun 13, 2018
2 parents 514124f + fde1a22 commit 752859b
Show file tree
Hide file tree
Showing 5 changed files with 4,244 additions and 4 deletions.
18 changes: 14 additions & 4 deletions hack/generate-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,25 @@ done

# collect_swagger gathers swagger files into a subdirectory
collect_swagger() {
SWAGGER_COMBINED="combined.swagger.json"
SWAGGER_DEST="$1/swagger"
EXPECTED_COLLISIONS="$2"
PRIMARY_SWAGGER=`mktemp`
echo '{}' > "${PRIMARY_SWAGGER}"

echo '{
"swagger": "2.0",
"info": {
"title": "Consolidate Services",
"description": "Description of all APIs",
"version": "version not set"
},
"paths": {}
}
' > "${PRIMARY_SWAGGER}"
/bin/mkdir -p "${SWAGGER_DEST}"
/bin/rm -f "${SWAGGER_DEST}/*.swagger.json"
/bin/rm -f ${SWAGGER_DEST}/*.swagger.json
/usr/bin/find "$1" -name '*.swagger.json' -exec /bin/mv '{}' "${SWAGGER_DEST}" \;
/usr/bin/find "${SWAGGER_DEST}" -name '*.swagger.json' -exec /usr/local/bin/swagger mixin -c "${EXPECTED_COLLISIONS}" "${PRIMARY_SWAGGER}" '{}' \+ > "${SWAGGER_DEST}/swagger.json"
/usr/bin/find "${SWAGGER_DEST}" -name '*.swagger.json' ! -name ${SWAGGER_COMBINED} -exec /usr/local/bin/swagger mixin -c "${EXPECTED_COLLISIONS}" "${PRIMARY_SWAGGER}" '{}' \+ > "${SWAGGER_DEST}/${SWAGGER_COMBINED}"
cat ${SWAGGER_DEST}/${SWAGGER_COMBINED} | jq -r 'del(.definitions[].properties[]? | select(."$ref"!=null and .description!=null).description) | del(.definitions[].properties[]? | select(."$ref"!=null and .title!=null).title)' > "${SWAGGER_DEST}/cleaned.swagger.json"
/bin/rm -f "${PRIMARY_SWAGGER}"
}

Expand Down
136 changes: 136 additions & 0 deletions reposerver/swagger/cleaned.swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"http",
"https"
],
"swagger": "2.0",
"info": {
"description": "Description of all APIs",
"title": "Consolidate Services",
"version": "version not set"
},
"paths": {},
"definitions": {
"repositoryFileList": {
"type": "object",
"title": "FileList returns the contents of the repo of a ListDir request",
"properties": {
"items": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"repositoryGetFileResponse": {
"type": "object",
"title": "GetFileResponse returns the contents of the file of a GetFile request",
"properties": {
"data": {
"type": "string",
"format": "byte"
}
}
},
"repositoryManifestResponse": {
"type": "object",
"properties": {
"manifests": {
"type": "array",
"items": {
"type": "string"
}
},
"namespace": {
"type": "string"
},
"params": {
"type": "array",
"items": {
"$ref": "#/definitions/v1alpha1ComponentParameter"
}
},
"revision": {
"type": "string"
},
"server": {
"type": "string"
}
}
},
"v1Time": {
"description": "Time is a wrapper around time.Time which supports correct\nmarshaling to YAML and JSON. Wrappers are provided for many\nof the factory methods that the time package offers.\n\n+protobuf.options.marshal=false\n+protobuf.as=Timestamp\n+protobuf.options.(gogoproto.goproto_stringer)=false",
"type": "object",
"properties": {
"nanos": {
"description": "Non-negative fractions of a second at nanosecond resolution. Negative\nsecond values with fractions must still have non-negative nanos values\nthat count forward in time. Must be from 0 to 999,999,999\ninclusive. This field may be limited in precision depending on context.",
"type": "integer",
"format": "int32"
},
"seconds": {
"description": "Represents seconds of UTC time since Unix epoch\n1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n9999-12-31T23:59:59Z inclusive.",
"type": "string",
"format": "int64"
}
}
},
"v1alpha1ComponentParameter": {
"type": "object",
"title": "ComponentParameter contains information about component parameter value",
"properties": {
"component": {
"type": "string"
},
"name": {
"type": "string"
},
"value": {
"type": "string"
}
}
},
"v1alpha1ConnectionState": {
"type": "object",
"title": "ConnectionState contains information about remote resource connection state",
"properties": {
"attemptedAt": {
"$ref": "#/definitions/v1Time"
},
"message": {
"type": "string"
},
"status": {
"type": "string"
}
}
},
"v1alpha1Repository": {
"type": "object",
"title": "Repository is a Git repository holding application configurations",
"properties": {
"connectionState": {
"$ref": "#/definitions/v1alpha1ConnectionState"
},
"password": {
"type": "string"
},
"repo": {
"type": "string"
},
"sshPrivateKey": {
"type": "string"
},
"username": {
"type": "string"
}
}
}
}
}
136 changes: 136 additions & 0 deletions reposerver/swagger/combined.swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"http",
"https"
],
"swagger": "2.0",
"info": {
"description": "Description of all APIs",
"title": "Consolidate Services",
"version": "version not set"
},
"paths": {},
"definitions": {
"repositoryFileList": {
"type": "object",
"title": "FileList returns the contents of the repo of a ListDir request",
"properties": {
"items": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"repositoryGetFileResponse": {
"type": "object",
"title": "GetFileResponse returns the contents of the file of a GetFile request",
"properties": {
"data": {
"type": "string",
"format": "byte"
}
}
},
"repositoryManifestResponse": {
"type": "object",
"properties": {
"manifests": {
"type": "array",
"items": {
"type": "string"
}
},
"namespace": {
"type": "string"
},
"params": {
"type": "array",
"items": {
"$ref": "#/definitions/v1alpha1ComponentParameter"
}
},
"revision": {
"type": "string"
},
"server": {
"type": "string"
}
}
},
"v1Time": {
"description": "Time is a wrapper around time.Time which supports correct\nmarshaling to YAML and JSON. Wrappers are provided for many\nof the factory methods that the time package offers.\n\n+protobuf.options.marshal=false\n+protobuf.as=Timestamp\n+protobuf.options.(gogoproto.goproto_stringer)=false",
"type": "object",
"properties": {
"nanos": {
"description": "Non-negative fractions of a second at nanosecond resolution. Negative\nsecond values with fractions must still have non-negative nanos values\nthat count forward in time. Must be from 0 to 999,999,999\ninclusive. This field may be limited in precision depending on context.",
"type": "integer",
"format": "int32"
},
"seconds": {
"description": "Represents seconds of UTC time since Unix epoch\n1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n9999-12-31T23:59:59Z inclusive.",
"type": "string",
"format": "int64"
}
}
},
"v1alpha1ComponentParameter": {
"type": "object",
"title": "ComponentParameter contains information about component parameter value",
"properties": {
"component": {
"type": "string"
},
"name": {
"type": "string"
},
"value": {
"type": "string"
}
}
},
"v1alpha1ConnectionState": {
"type": "object",
"title": "ConnectionState contains information about remote resource connection state",
"properties": {
"attemptedAt": {
"$ref": "#/definitions/v1Time"
},
"message": {
"type": "string"
},
"status": {
"type": "string"
}
}
},
"v1alpha1Repository": {
"type": "object",
"title": "Repository is a Git repository holding application configurations",
"properties": {
"connectionState": {
"$ref": "#/definitions/v1alpha1ConnectionState"
},
"password": {
"type": "string"
},
"repo": {
"type": "string"
},
"sshPrivateKey": {
"type": "string"
},
"username": {
"type": "string"
}
}
}
}
}
Loading

0 comments on commit 752859b

Please sign in to comment.