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: [PL-56199]: support Open API yaml URL with Github API #34

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

namanharness
Copy link

@namanharness namanharness commented Aug 16, 2024

Summary

Since our harness core repo was converted into private repository, we had to manually create a yaml file in https://github.com/harness/react-api-client repo and add the openApi yaml content for respective service to generate swagger.

With this we are enabling back generation of services using url ("openApi file path" would be better choice of words).
To achieve this user will require

  • GITHUB Personal Access Token
  • Path to service's openApi yaml in harness core
  • Organization, Repository and Branch name

Here is an attached video, where we are trying to generate idp-service swagger

https://drive.google.com/file/d/1lFrfwnAq-H3fFVPVj0ld_LtyUSH9WSFL/view?usp=sharing

Screenshots

NA

Contributor license agreement

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -10,6 +10,14 @@ import { has } from 'lodash-es';

const DIR_NAME = getDirNameForCurrentFile(import.meta);

// helpers when when working with url to generate service
const DEFAULT_BRANCH = 'develop';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are times when we need to generate from feature branches and deploy to PR env.
We should handle that use case too.

Possibly, take branch as input via env variable?

Suggested change
const DEFAULT_BRANCH = 'develop';
const DEFAULT_BRANCH = process.env.GITHUB_BRANCH || 'develop';

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done and tested this with a new branch and passing branch name in env variable

yashr-harness
yashr-harness previously approved these changes Aug 26, 2024
@@ -0,0 +1,4 @@
GITHUB_PAT=GITHUB_PAT
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we avoid hardcoded design dependency on Github?
considering that we have most of our repos moving to Harness Code now, we should support querying harness0.harness.io with the Harness PAT as well.

a simpler, more generic design would be to just take a complete url as a param, instead of taking org + repo + branch and constructing github urls via "magic".

@@ -53,3 +64,15 @@ export function getDirNameForCurrentFile(meta: ImportMeta): string {
export function pathToTemplate(val: string): string {
return val.replace(/\{/g, '${');
}

export function b64DecodeUnicode(str: any) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to avoid the need for this decoder? few concerns:

  1. it's very specific to github it seems
  2. it looks like magic code.. why is it doing what it's doing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github API returns bas64 encoded content, hence need to decode the content.

@namanharness namanharness reopened this Sep 28, 2024
@namanharness namanharness reopened this Oct 29, 2024
@harness harness deleted a comment from bot2-harness Oct 29, 2024
@harness harness deleted a comment from bot2-harness Oct 29, 2024
@namanharness namanharness reopened this Nov 29, 2024
@harness harness deleted a comment from bot2-harness Nov 29, 2024
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.

6 participants