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

Fix code generation for Chaos Center Authentication API #4537

Open
3 tasks
smitthakkar96 opened this issue Mar 17, 2024 · 6 comments
Open
3 tasks

Fix code generation for Chaos Center Authentication API #4537

smitthakkar96 opened this issue Mar 17, 2024 · 6 comments

Comments

@smitthakkar96
Copy link
Contributor

smitthakkar96 commented Mar 17, 2024

While addressing issue #4236, I introduced a new endpoint to the Auth Server's capabilities. Following the steps in this documentation, I regenerated the swagger.json.

During frontend development, I noticed the auth client is generated using oats, but the oats config points to a manually generated swagger.json at a different location, not the auto-generated one. Switching to the auto-generated swagger.json led to several issues:

Encountered Issuess

Missing Version

This can be corrected by setting @Version here.

⠋ Generating spec for: authTypeError: Cannot read properties of undefined (reading 'startsWith')
    at loadSpecFromFileOrUrl (file:///Users/s.thakkar/projects/litmus/chaoscenter/web/node_modules/@harnessio/oats-cli/dist/loadSpecFromFileOrUrl.mjs:58:42)
    at async importSpec (file:///Users/s.thakkar/projects/litmus/chaoscenter/web/node_modules/@harnessio/oats-cli/dist/importSpec.mjs:63:30)
✖ Generating spec for: auth

Missing operationId

This can be corrected by adding @ID for every handler. Example

// FetchUsers		godoc
//
//	@Description	Fetch users.
//	@Tags			UserRouter
//	@Accept			json
//	@Produce		json
//	@Failure		401	{object}	response.ErrUnauthorized
//	@Failure		500	{object}	response.ErrServerError
//	@Success		200	{object}	response.UserResponse{}
//	@Router			/users [get]
//	@ID				users
⠋ Generating spec for: authError: Every path must have a operationId - No operationId set for post /auth/accept_invitation
    at file:///Users/s.thakkar/projects/litmus/chaoscenter/web/node_modules/@harnessio/oats-cli/dist/pathHelpers.mjs:38:23
    at Array.forEach (<anonymous>)
    at file:///Users/s.thakkar/projects/litmus/chaoscenter/web/node_modules/@harnessio/oats-cli/dist/pathHelpers.mjs:32:23
    at Array.forEach (<anonymous>)
    at processPaths (file:///Users/s.thakkar/projects/litmus/chaoscenter/web/node_modules/@harnessio/oats-cli/dist/pathHelpers.mjs:29:38)
    at Object.generate (file:///Users/s.thakkar/projects/litmus/chaoscenter/web/node_modules/@harnessio/oats-plugin-react-query/dist/generateReactQueryHooks.mjs:26:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async generateOpenAPISpec (file:///Users/s.thakkar/projects/litmus/chaoscenter/web/node_modules/@harnessio/oats-cli/dist/generateOpenAPISpec.mjs:27:32)
    at async importSpec (file:///Users/s.thakkar/projects/litmus/chaoscenter/web/node_modules/@harnessio/oats-cli/dist/importSpec.mjs:63:30)
✖ Generating spec for: auth

After resolving these, I observed a huge diff in the client code, likely due to some responses not being composed of struct types and missing annotations on some structs.

Screenshot 2024-03-17 at 15 13 43

Proposed Solution

  • Add missing version information
  • Add @ID for all routes
  • Annotate response structs
@rootxrishabh
Copy link

@smitthakkar96 I would like to work on this!

@smitthakkar96
Copy link
Contributor Author

smitthakkar96 commented Mar 19, 2024

@rootxrishabh thanks for expressing interest. I am not tackling this currently so please go ahead but I would suggest aligning with the maintainers first. You can also join the slack channel https://app.slack.com/client/T09NY5SBT/CNXNB0ZTN

cc: @Saranya-jena @neelanjan00 @namkyu1999

@rootxrishabh
Copy link

@smitthakkar96 I had joined the slack channel earlier. I will post my approach here before making a PR to get everyone's opinion. Sounds good?

@smitthakkar96
Copy link
Contributor Author

Yup sounds good

@neelanjan00
Copy link
Member

CC: @amityt can you please take a look?

@rootxrishabh rootxrishabh removed their assignment Apr 3, 2024
@rootxrishabh
Copy link

Apologies folks, I currently don't have the bandwidth to complete this. Please feel free to take it up!

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

No branches or pull requests

3 participants