-
-
Notifications
You must be signed in to change notification settings - Fork 371
Adjust names of security schemes to match prefixed name #3861
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
73a8153
91ab2b0
526eeba
e7cf98b
7339164
7579098
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,15 +42,20 @@ export function getResolvedInput({ | |
| resolvedInput.path = url.fromFileSystemPath(resolvedInput.path); | ||
| resolvedInput.type = 'file'; | ||
| } else if (!resolvedInput.path && pathOrUrlOrSchema && typeof pathOrUrlOrSchema === 'object') { | ||
| if ('$id' in pathOrUrlOrSchema && pathOrUrlOrSchema.$id) { | ||
| if ( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @StratusFearMe21 why did you need to add this piece? I see the test fails without it, but I'm concerned about tying internals to OpenAPI/Swagger like this
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That piece is so that the regression test can set
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand, is this just to satisfy the test suite? Or is this needed for a real world usage?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I put it there to satisfy the test suite, but if you were using this package in the real world, passing multiple JSON objects to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be better to handle that as a separate issue. I'm also concerned about this package, it feels like it's doing too much too poorly because I'm sure there are other similar edge cases we just didn't run into yet
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why
|
||
| ('openapi' in pathOrUrlOrSchema && pathOrUrlOrSchema.openapi) || | ||
| ('swagger' in pathOrUrlOrSchema && pathOrUrlOrSchema.swagger) | ||
| ) { | ||
| resolvedInput.schema = pathOrUrlOrSchema; | ||
| resolvedInput.type = 'json'; | ||
| if ('$id' in pathOrUrlOrSchema && pathOrUrlOrSchema.$id) | ||
| resolvedInput.path = pathOrUrlOrSchema.$id as string; | ||
| } else if ('$id' in pathOrUrlOrSchema && pathOrUrlOrSchema.$id) { | ||
| // when schema id has defined an URL should use that hostname to request the references, | ||
| // instead of using the current page URL | ||
| const { hostname, protocol } = new URL(pathOrUrlOrSchema.$id as string); | ||
| resolvedInput.path = `${protocol}//${hostname}:${protocol === 'https:' ? 443 : 80}`; | ||
| resolvedInput.type = 'url'; | ||
| } else { | ||
| resolvedInput.schema = pathOrUrlOrSchema; | ||
| resolvedInput.type = 'json'; | ||
| } | ||
|
pullfrog[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
|
|
@@ -385,7 +390,8 @@ export class $RefParser { | |
| const baseName = (p: string) => { | ||
| try { | ||
| const withoutHash = p.split('#')[0]!; | ||
| const parts = withoutHash.split('/'); | ||
| const withoutTrailingSlash = withoutHash.replace(/\/+$/, ''); | ||
| const parts = withoutTrailingSlash.split('/'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @StratusFearMe21 why is this change needed? Reverting it doesn't fail tests
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, I didn't mean to keep that in this PR, that's my mistake. It fixes another bug where if the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want to open a separate pull request for that? |
||
| const filename = parts[parts.length - 1] || 'schema'; | ||
| const dot = filename.lastIndexOf('.'); | ||
| const raw = dot > 0 ? filename.substring(0, dot) : filename; | ||
|
|
@@ -461,6 +467,14 @@ export class $RefParser { | |
| } | ||
| } else if (k === 'tags' && Array.isArray(v) && v.every((x) => typeof x === 'string')) { | ||
| out[k] = v.map((t) => tagMap.get(t) || t); | ||
| } else if (k === 'security' && Array.isArray(v)) { | ||
| out[k] = v.map((s) => { | ||
| const securityScheme: Record<string, any> = {}; | ||
| for (const [key, value] of Object.entries(s)) { | ||
| securityScheme[`${opIdPrefix}_${key}`] = value; | ||
| } | ||
| return securityScheme; | ||
| }); | ||
| } else if (k === 'operationId' && typeof v === 'string') { | ||
| out[k] = unique(usedOpIds, `${opIdPrefix}_${v}`); | ||
| } else { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.