Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added API.V1beta2.Resource to handle the path and request ID #23

Closed
wants to merge 3 commits into from

Conversation

x-0o0
Copy link
Contributor

@x-0o0 x-0o0 commented Sep 26, 2023

Description of the change

  func generateMessage(_ model: String) -> GenerateMessageResource {
    - GenerateMessageResource(path: "\(path)/\(model):generateMessage")
    + GenerateMessageResource(path: "\(path)/\(model):\(Resource.generateMessage.rawValue)")
  }

  struct GenerateMessageResource {
    func post(_ body: GenerateMessageRequest? = nil) -> Request<GenerateMessageResponse> {
      - Request(path: path, method: .post, body: body, id: "generativelanguage.models.generateMessage")
      + Request(path: path, method: .post, body: body, id: Resource.generateMessage.id)
    }
  }

Motivation

I added an Enum called Resource in API.V1beta2 to manage frequently used string values.

Type of change

Other - Improvement

Checklist

  • I have performed a self-review of my code.
  • I have added detailed comments to my code where applicable.
  • I have verified that my change does not break existing code.
  • My PR is based on the latest changes of the main branch (if unsure, please run git pull --rebase upstream main).
  • I am familiar with the Google Style Guide for the language I have coded in.
  • I have read through the Contributing Guide and signed the Contributor License Agreement.

@github-actions github-actions bot added the status:awaiting review PR awaiting review from a maintainer label Sep 26, 2023
@peterfriese
Copy link
Collaborator

Thanks for the PR, @jaesung-0o0 !

Since we're using CreateAPI to generate the code for the API from the discovery document generativelanguage-v1beta3.json, all the strings you see are generated from the same machine-readable description file that is used to build the backend implementation.

Making any changes to this increases the risk of introducing typos, so I'd rather stick to the current process.

@github-actions github-actions bot removed the status:awaiting review PR awaiting review from a maintainer label Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants