-
Notifications
You must be signed in to change notification settings - Fork 16
feat: supports fragment in remote reference #83
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
feat: supports fragment in remote reference #83
Conversation
The testing issue is ticketed: #84 |
return !!(fs.existsSync(entryPoint) && fs.statSync(entryPoint).isFile()); | ||
} | ||
|
||
public static loadJsonOrYaml(entryPoint: string): any { | ||
const hasFragment: boolean = new RegExp(this.FRAGMENT).test(entryPoint); | ||
const hasFragment = entryPoint.indexOf(this.FRAGMENT) !== -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. Thankyou!
Surely this is a necessary fix, please confirm as the test is failing in a windows environment. |
You can write use cases in your tests to verify your supposed behavior! You can update snapshots to maintain them in the future! If this is difficult, please include an example in the Description of your Pull Request. I will add it later! Thanks your cooperation, @karupanerura . |
@Himenon Thank you for the guide! I added the basic snapshot test for this case. |
CI is maybe fixed by ca3da4b |
name: MIT | ||
|
||
servers: | ||
- url: "http://dev.remote.ref.access.test/v1/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: .test
TLD is recommended to use in test cases. refs: https://www.rfc-editor.org/rfc/rfc2606#page-2
@@ -29,4 +29,9 @@ describe("Typedef with template", () => { | |||
const text = Utils.replaceVersionInfo(generateCode); | |||
expect(text).toMatchSnapshot(); | |||
}); | |||
test("remote-ref-access", () => { | |||
const generateCode = fs.readFileSync(path.join(__dirname, "../code/typedef-with-template/remote-ref-access.ts"), { encoding: "utf-8" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { posix as path } from "path";
Oh, sorry. Please change import path
. Like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"path" does not work properly in Windows environment, use posix path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another problem ...
#87
targetPath = referencePoint.substring(fragmentIndex + 2); | ||
} else { | ||
const relativePathFromEntryPoint = path.relative(path.dirname(entryPoint), referencePoint); // components/hoge/fuga.yml | ||
const pathArray: string[] = relativePathFromEntryPoint.split(path.sep); // ["components", "hoge", "fuga"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this file also does not use the posix path, CI in the Windows environment is considered to have failed.
- import * as path from "path";
+ import { posix as path } from "path";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another problem ...
#87
I fixed in #87 and merge this pull request changed. Thanks your cooperation, @karupanerura ! |
It was released in npm at 0.19.0. Thank you! |
Summary
If any fragment is included in a remote URL reference, it always fail to load file.
Test Plan
The latest test running is failed on CI:
refs. https://github.com/Himenon/openapi-typescript-code-generator/actions/runs/2532596212
And it failed on my environment too. So I hard to test it. 😢