launchdarkly / ld-openapi Goto Github PK
View Code? Open in Web Editor NEWOpen API specification for the LaunchDarkly REST API
License: Other
Open API specification for the LaunchDarkly REST API
License: Other
is this still the correct url for consumers?:
https://launchdarkly.github.io/ld-openapi/swagger.yaml
it is quite out of date, so i am compiling this locally and using output at the moment.
i also notice the swagger naming of tags in this repo no longer matches the published swagger file. eg. 'flags' has become 'Feature flags'. this means that the generated client from swagger-js results in a different interface for api calls - breaking contract and anything that depends on it.
ie.
old api containing functions:
(projects={}, environments={}, flags={}, users={}, user settings={}, audit log={}, webhooks={}, root={})
new api containing functions
(Projects={}, Environments={}, Feature flags={}, Users={}, User settings={}, Audit log={}, Webhooks={}, Custom roles={}, Team members={}, Root={})
for example this call using the generated client no longer works because the 'flags' api no longer exists.
this.apiClient.apis.flags.getFeatureFlags({ projectKey: projectKey });
refer: https://github.com/wyvern8/launchdarkly-nodeutils which works with the copy taken from published url, but not the swagger generated from this repo. (update: repo is updated to match new structures)
here are the notes as to how the api is generated
https://github.com/swagger-api/swagger-js#tags-interface
Per https://docs.python.org/3/whatsnew/3.7.html async
is now a reserved keyword. This causes the generated client to break when using python 3.7
with the following error message.
(venv) ld-mbp:SupportService levlaz$ python cli.py
Traceback (most recent call last):
File "cli.py", line 1, in <module>
from launchdarkly_api import Configuration, ProjectsApi, ApiClient
File "/Users/levlaz/git/SupportService/lib/api-client-python/launchdarkly_api/__init__.py", line 19, in <module>
from launchdarkly_api.api.audit_log_api import AuditLogApi
File "/Users/levlaz/git/SupportService/lib/api-client-python/launchdarkly_api/api/__init__.py", line 6, in <module>
from launchdarkly_api.api.audit_log_api import AuditLogApi
File "/Users/levlaz/git/SupportService/lib/api-client-python/launchdarkly_api/api/audit_log_api.py", line 139
async=params.get('async'),
^
SyntaxError: invalid syntax
Hey,
Thanks for the excellent OpenAPI specification. I've successfully used it to generate a Go client library, and it's been working great overall! ๐
I've been using the Go library as part of my brand-new Terraform provider for LaunchDarkly:
https://github.com/mlafeldt/terraform-provider-launchdarkly
At this moment, the provider allows to manage LaunchDarkly projects, environments, and feature flags. While it works great in general, there are at least two known issues that make development of a proper provider kind of difficult:
launchdarkly_project
and launchdarkly_environment
resources don't handle this case in a good way yet. As a workaround, it's possible to import these special environments via terraform import
.I hope you can see how providing API endpoints for creating projects and environments, with the former interfering with the latter, can cause the mentioned problems for API consumers. As far as I can see, there's no way to change this surprising behavior. Please advise.
Some POST methods do not return the created object.
FeatureFlagStatus
is missing parent
link in their _links
properties. The parent
should be a link to the feature flag. Because it's missing from the definition, it's impossible to link statuses to feature flags.
The server returns parent
links, but the generated client api ignores them because they're not in the spec
This is how I have been usingld-openapi
from bravado.client import SwaggerClient
client_api = SwaggerClient.from_url('https://launchdarkly.github.io/ld-openapi/openapi.json')
As of 2.0.20, it leads to this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/savinay/.pyenv/versions/2.7.14/lib/python2.7/site-packages/bravado/client.py", line 107, in from_url
return cls.from_spec(spec_dict, spec_url, http_client, config)
File "/Users/savinay/.pyenv/versions/2.7.14/lib/python2.7/site-packages/bravado/client.py", line 134, in from_spec
spec_dict, origin_url, http_client, config,
File "/Users/savinay/.pyenv/versions/2.7.14/lib/python2.7/site-packages/bravado_core/spec.py", line 185, in from_dict
spec.build()
File "/Users/savinay/.pyenv/versions/2.7.14/lib/python2.7/site-packages/bravado_core/spec.py", line 197, in build
self._validate_spec()
File "/Users/savinay/.pyenv/versions/2.7.14/lib/python2.7/site-packages/bravado_core/spec.py", line 193, in _validate_spec
http_handlers=self.get_ref_handlers(),
File "/Users/savinay/.pyenv/versions/2.7.14/lib/python2.7/site-packages/swagger_spec_validator/validator20.py", line 163, in validate_spec
http_handlers=http_handlers,
File "/Users/savinay/.pyenv/versions/2.7.14/lib/python2.7/site-packages/swagger_spec_validator/common.py", line 29, in wrapper
sys.exc_info()[2])
File "/Users/savinay/.pyenv/versions/2.7.14/lib/python2.7/site-packages/swagger_spec_validator/common.py", line 24, in wrapper
return method(*args, **kwargs)
File "/Users/savinay/.pyenv/versions/2.7.14/lib/python2.7/site-packages/swagger_spec_validator/validator20.py", line 215, in validate_json
cls=Draft4Validator,
File "/Users/savinay/.pyenv/versions/2.7.14/lib/python2.7/site-packages/swagger_spec_validator/ref_validators.py", line 52, in validate
instance_cls(schema, *args, **kwargs).validate(instance)
File "/Users/savinay/.pyenv/versions/2.7.14/lib/python2.7/site-packages/jsonschema/validators.py", line 353, in validate
raise error
swagger_spec_validator.common.SwaggerValidationError: ("{u'description': u'Returns timeseries data and all sdk versions.', u'schema': {u'x-scope': ['https://launchdarkly.github.io/ld-openapi/openapi.json'], u'$ref': u'#/definitions/MAUbyCategory'}} is not valid under any of the given schemas\n\nFailed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^/']['properties']['get']['properties']['responses']['patternProperties']['^([0-9]{3})$|^(default)$']:\n {'oneOf': [{'$ref': '#/definitions/response'},\n {'$ref': '#/definitions/jsonReference'}]}\n\nOn instance['paths'][u'/usage/mau/bycategory']['get']['responses'][u'200']:\n {u'description': u'Returns timeseries data and all sdk versions.',\n u'schema': {u'$ref': u'#/definitions/MAUbyCategory',\n u'x-scope': ['https://launchdarkly.github.io/ld-openapi/openapi.json']}}", <ValidationError: "{u'description': u'Returns timeseries data and all sdk versions.', u'schema': {u'x-scope': ['https://launchdarkly.github.io/ld-openapi/openapi.json'], u'$ref': u'#/definitions/MAUbyCategory'}} is not valid under any of the given schemas">)
The work around for now is to set validate_swagger_spec = False
like this:
from bravado.client import SwaggerClient
OPTS = { 'validate_swagger_spec': False }
client_api = SwaggerClient.from_url(
'https://launchdarkly.github.io/ld-openapi/openapi.json',
config=OPTS
)
The error is indicating that the issue is here: a7072c8#diff-8d2741e7ceded60530075c3064376672R71
ld-openapi/spec/parameters.yaml
Line 129 in a85c272
Is this meant to be 'env'? - it appears that is what the api actually expects. when i generate a client with swagger-js and call functions that refer to this, the url used has querystring 'environmentKeyQuery' rather than 'env' eg:
https://app.launchdarkly.com/api/v2/flags/nab/demo-feature?environmentKeyQuery=dev
so at the moment i need to translate this, ie:
return Swagger({
spec: json,
usePromise: true,
requestInterceptor: req => {
req.headers.Authorization = API_TOKEN;
// hack - fix incorrect qs mapping..
req.url = req.url.replace('environmentKeyQuery', 'env');
return req;
}
});
From some empirical testing against the live API it appears that the getUser operation ("GET /api/v2/users/project/environment/user_key") returns a UserRecord, not a User.
Can you confirm this is the desired behaviour? If so I'm happy to submit a PR to correct this.
Thanks.
It looks like the problem solved by this script exists elsewhere. An example is #/definitions/CustomRoleKeyOrId
I did some research and it looks like there is no real workaround for v2 of Swagger/OpenAPI. v3 has been released, but there is no built-in generator for many of the platforms this repo is configured to use.
For now I propose expanding all the $ref
s instead of adding more to the script.
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.