Skip to content

Commit

Permalink
Add summary and archived query params to flags endpoint (#37)
Browse files Browse the repository at this point in the history
* Add summary and archived query params to flags endpoint
* Add bravado validation
* Bump version
  • Loading branch information
ashanbrown authored Nov 19, 2019
1 parent 4d78e70 commit f775582
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
sudo mv ./swagger-codegen-cli.jar /usr/local/bin
sudo chmod +x /usr/local/bin/swagger-codegen
- run:
name: Install pip
command: sudo apt install python-pip

- run:
name: Loading previous client repos
command: |
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SHELL = /bin/bash
VERSION=$(shell cat $(TARGETS_PATH)/openapi.json | jq -r '.info.version' )
REVISION:=$(shell git rev-parse --short HEAD)

SWAGGER_VERSION=2.4.0
SWAGGER_VERSION=2.4.8
SWAGGER_JAR=swagger-codegen-cli-${SWAGGER_VERSION}.jar
SWAGGER_DOWNLOAD_URL=http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/${SWAGGER_VERSION}/${SWAGGER_JAR}

Expand Down Expand Up @@ -99,9 +99,11 @@ load_prior_targets:
git submodule add -b gh-pages $(REPO_USER_URL)/ld-openapi$(RELEASE_SUFFIX) gh-pages

openapi_yaml: $(SWAGGER_JAR) $(TARGETS_PATH) $(MULTI_FILE_SWAGGER) $(CHECK_CODEGEN)
pip install bravado
$(MULTI_FILE_SWAGGER) openapi.yaml > $(TARGET_OPENAPI_JSON)
$(MULTI_FILE_SWAGGER) -o yaml openapi.yaml > $(TARGET_OPENAPI_YAML)
$(CODEGEN) validate -i $(TARGET_OPENAPI_YAML)
python scripts/bravado-validate.py

$(TARGETS_PATH):
mkdir -p $@
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ http://azimi.me/2015/07/16/split-swagger-into-smaller-files.html

## Compiling the spec

The spec is joined from multiple files using a multi-file Swagger tool. To compile the just spec run `make openapi_yaml`.
The spec is joined from multiple files using a multi-file Swagger tool. To compile just the spec run `make openapi_yaml`.

Alternatively, you can test a multi-file Swagger spec using VSCode, or by following these instructions for the online editor:

Expand All @@ -31,7 +31,7 @@ We use the spec to build some internals tools in go. Tests for other specs are

Server/client code for the API can be automatically generated. To generate the code:

1. Ensure that you have `wget`, `yarn`, and `jq` installed.
1. Ensure that you have `wget`, `yarn`, `jq`, and `pip` installed.
1. Run the `generate` command:
```
> make
Expand Down
6 changes: 6 additions & 0 deletions scripts/bravado-validate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from bravado.client import SwaggerClient
from bravado.swagger_model import load_file

# Merely generating a Bravado client is enough to validate the spec.
# Actually using the client is unnecessary.
client = SwaggerClient.from_spec(load_file('./targets/openapi.yaml'))
2 changes: 1 addition & 1 deletion spec/info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ contact:
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 2.0.21
version: 2.0.22
12 changes: 12 additions & 0 deletions spec/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@ EnvironmentKeyQuery:
required: false
description: By default, each feature will include configurations for each environment. You can filter environments with the env query parameter. For example, setting env=production will restrict the returned configurations to just your production environment.
type: string
SummaryQuery:
name: summary
in: query
required: false
description: By default in api version >= 1, flags will _not_ include their list of prerequisites, targets or rules. Set summary=0 to include these fields for each flag returned.
type: string
ArchivedQuery:
name: archived
in: query
required: false
description: When set to 1, archived flags will be included in the list of flags returned. By default, archived flags are not included in the list of flags.
type: string
FeatureFlagKey:
name: featureFlagKey
in: path
Expand Down
2 changes: 2 additions & 0 deletions spec/paths/flags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Flags:
parameters:
- $ref: '#/parameters/ProjectKey'
- $ref: '#/parameters/EnvironmentKeyQuery'
- $ref: '#/parameters/SummaryQuery'
- $ref: '#/parameters/ArchivedQuery'
- $ref: '#/parameters/Tag'
responses:
'200':
Expand Down

0 comments on commit f775582

Please sign in to comment.