- Create a new or modify YAML OpenAPI spec for Label Studio endpoints.
For example,
./fern/openapi/resources/comments.yaml:paths: /api/comments: get: ... post: ... components: schemas: Comments: ... requestBodies: api_comments_create: ...
paths: contain API pathcomponents(optional): components to reuse inresponsesrequestBodies(optional): request bodies specification to reuse in requests’requestBody
- Add
$refreferences inoverrides.yaml:this will define the public methods calledpaths: /api/comments/: get: $ref: "./resources/comments.yaml#/paths/~1api~1comments/get" x-fern-sdk-group-name: comments x-fern-sdk-method-name: list x-fern-audiences: - public post: $ref: "./resources/comments.yaml#/paths/~1api~1comments/post" x-fern-sdk-group-name: comments x-fern-sdk-method-name: create x-fern-audiences: - public
client.comments.list()andclient.comments.create(). Read more about Fern's OpenAPI extensions - Create a PR in
label-studio-client-generatorusing Follow-Merge workflow. For example, push a branch calledfb-PRJ-123-update-comments-api - Ensure PR is created in
label-studio-sdkand Label Studio repo - Update added endpoints in Django code.
- Add integration tests with newly added functions in LS:
https://github.com/HumanSignal/label-studio/tree/develop/label_studio/tests/sdk
swagger2openapi --yaml --outfile ./fern/openapi/openapi.yaml http://localhost:8080/docs/api?format=openapi
fern generate --docs
fern docs dev
Go to fern/openapi/overrides.yaml and modify fields keeping the structure as in fern/openapi/openapi.yaml. For example
paths:
/api/projects/:
post:
summary: List of Projects
-->
paths:
/api/projects/:
post:
summary: A new title to be replaced
get:
description: and another update in description `/get` endpoint.
- Ensure
label-studio-sdkis at the same level as this generator directory, for example:
parent/
├── label-studio-client-generator/
└── label-studio-sdk/
- Ensure you have a local Label Studio instance running in docker container with name
label-studio-enterprise-app-1. - Run
./localgen.shto generate SDK locally. The package will be generated inlabel-studio-client-generator/label_studio_sdk/directory. - Test the generated SDK by running
python -c "from label_studio_sdk import LabelStudio".