Skip to content

Auto-generate rest client #364

Closed as not planned
Closed as not planned

Description

@callumforrester

We should auto-generate the rest client code rather than handcraft it. Replacing blueapi.cli.rest.BlueapiRestClient with something generated with swagger-codegen or similar

Activity

  1. added
    enhancement
    c: rest api
    c: client
    c: cli
    on Feb 5, 2024
  2. stan-dot commented on Mar 8, 2024

    @stan-dot
    Contributor
  3. self-assigned this
    on Mar 8, 2024
  4. stan-dot commented on Mar 11, 2024

    @stan-dot
    Contributor

    @callumforrester need more info on the use case for this client. Will it be called from a Python GUI app? Right now it's only the CLI client.

    most generators focus on the Typescript use case. The documentation for the Python one isn't that great https://openapi-generator.tech/docs/generators/python/

  5. stan-dot commented on Mar 12, 2024

    @stan-dot
    Contributor

    ah I see there's a huge benefit from autocompletion - but I'm not sure if I got it running on my device

  6. stan-dot commented on Mar 12, 2024

    @stan-dot
    Contributor

    what is the target use case for building this CLI? Testing the API? running it? I've looked into autogeneration and there are libraries for that, but then we'd need to write custom CLI to it. I haven't noticed a library that would produce the CLI at the same time. We would need then to manually update the cli code on every regeneration. there is a plethora of tools for rapid api testing or calling remote servers. They are much more powerful than custom CLI, with more support.

    If we go with recommending a GUI option like Postman, users could even have an account and keep their API call data across devices. If not Postman we can consider some alternatives:

    In conclusion, using a third party instead of in house CLI would be beneficial.

    In regards to the client for a GUI python / web app that can be done quite easily. I will add a github action workflow soon

  7. callumforrester commented on Mar 14, 2024

    @callumforrester
    ContributorAuthor

    For now I think the only use case is auto-generating a version of this class:

    class BlueapiRestClient:

    Future classes that fulfil the use cases you suggest can build on top of it.

  8. stan-dot commented on Mar 14, 2024

    @stan-dot
    Contributor

    I mean use case in the broad sense of having the Python Rest client in the first place

  9. callumforrester commented on Mar 26, 2024

    @callumforrester
    ContributorAuthor

    Yes, the use case is mainly testing/debugging. The reason for writing this and not just using rest tools is that
    the CLI doesn't just make rest calls though, it combines several rest calls together for the user's convenience and also listens to the message bus via a query-then-subscribe model.

  10. stan-dot commented on Mar 28, 2024

    @stan-dot
    Contributor

    if the client is generated, we could publish it as a pypi package and have cli as a separate project. admittedly if Kubernetes is the inspiration, they have a build setup with a monorepo.

    depends on what is the target use case I guess

    https://github.com/kubernetes/kubernetes/blob/master/build/root/Makefile

  11. stan-dot commented on Mar 28, 2024

    @stan-dot
    Contributor

    For most cases, especially in a microservices architecture or when sharing clients among multiple teams, the registry approach aligns better with continuous integration and delivery practices. It optimizes reuse and version management, although it requires a bit more setup initially.

    chatgpt has an opinion

  12. stan-dot commented on Apr 4, 2024

    @stan-dot
    Contributor

    note: java has a build repo in gitlab maven using this dynamically, with version set manually on release. not scalable

  13. stan-dot commented on Apr 22, 2024

    @stan-dot
    Contributor

    note: this setup has a tighter loop for DX rather that leaving this to CI. can be explored next https://chat.openai.com/share/eb5d3fb7-5024-4146-a50a-4cda7c37c70f

  14. stan-dot commented on Apr 29, 2024

    @stan-dot
    Contributor

    working on this now

  15. stan-dot commented on Apr 29, 2024

    @stan-dot
    Contributor

    the generator produces not one file, but a whole project:
    `
    image

    `

  16. stan-dot commented on Apr 29, 2024

    @stan-dot
    Contributor
  17. linked a pull request that will close this issuetesting client gen #441on Apr 29, 2024
  18. stan-dot commented on May 20, 2024

    @stan-dot
    Contributor

    based on the #449 pydantic 2 migration we'll be able to use the generic python generator instead of the odd pydantic-v1 version. It makes no sense to migrate at the moment to v1 if after #449 we'd need to migrate again. delaying this right now

  19. removed their assignment
    on May 20, 2024
  20. abbiemery commented on Feb 25, 2026

    @abbiemery
    Contributor

    Closed as won't do. Current client sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: clic: clientc: rest apienhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions