-
Notifications
You must be signed in to change notification settings - Fork 88
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
chore(backend): update OpenAPI specs #799
Conversation
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.
I'm confused, why are we fetching the specs now instead of updating URLs in env files?
Here's the previous two related pr's:
The Rafiki specific specs use the shared Open Payments schemas file So it is fetched instead of updating the I suggested also fetching the relevant Open Payments spec(s) |
curl -o "$OUTDIR/resource-server.yaml" https://raw.githubusercontent.com/interledger/open-payments/b363d33038fe789e5388f04f80ddd06a4fa97093/openapi/resource-server.yaml | ||
curl -o "$OUTDIR/schemas.yaml" https://raw.githubusercontent.com/interledger/open-payments/b363d33038fe789e5388f04f80ddd06a4fa97093/openapi/schemas.yaml |
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.
Can we also update the open-payments
commit version in this PR
or would it make sense to export these from open-payments
? so we can be sure both are using the same spec? This does seem vaguely familiar though... have we discussed this before?
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.
We could even do it for both of backend
and auth
projects since open-payments
contains both, which would eliminate the need for the packages/backend/src/openapi/auth-server.yaml
dependency
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.
would it make sense to export these from open-payments?
I'm favor of defining the (default) commit in a single place.
It seems like that could happen while still allowing subsequent local tinkering of the specs
#684 (comment)
which would eliminate the need for the packages/backend/src/openapi/auth-server.yaml dependency
Did you mean resource-server.yaml
?
packages/backend/src/index.ts
Outdated
const authServerSpec = await createOpenAPI( | ||
path.resolve(__dirname, './openapi/auth-server.yaml') | ||
) | ||
const resourceServerSpec = await createOpenAPI( | ||
path.resolve(__dirname, './openapi/resource-server.yaml') | ||
) |
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.
Could we add a good error message here, for when the files can't be found?
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.
As is, we get something like
ResolverError: Error opening file "/home/brandon/rafiki/packages/auth/src/openapi/auth-server.yaml"
at ReadFileContext.callback (node_modules/.pnpm/@[email protected]/node_modules/@apidevtools/json-schema-ref-parser/lib/resolvers/file.js:52:20)
Are you thinking of having it mention the command to fetch the schemas?
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.
Yes, that's what I was thinking, something along the lines of "Could not find Open API schema files. Did you run <command>
?"
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.
As long we remember not to change the command 😅
README.md
Outdated
pnpm --filter auth fetch-schemas | ||
pnpm --filter backend fetch-schemas |
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.
can we add a root level command?
"localenv:fetch-op-schemas": "pnpm --filter auth --filter backend fetch-schemas"
, and then include it as part of the local env setup readme?
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.
I was thinking that devs would run through this environment setup before doing local env, but I guess that's not entirely necessary.
https://github.com/interledger/rafiki#environment-setup
Should we split out installing node & pnpm and fetching schemas into a separate prerequisite section?
I also noticed that as is it shouldn't work to have tests before fetch schemas.
Restructure local development / localenv instructions.
ef3903c
to
bb4be91
Compare
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.
Once the specs stabilize it would be good to have them be defined in a singular place, even like with the exported commit hash as you suggested - I am a bit worried about specs diverging accidentally
idpSpec | ||
container.singleton('openApi', async (deps: IocContract<AppServices>) => { | ||
try { | ||
const authServerSpec = await createOpenAPI( |
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.
what do you think of openPaymentsAuthServerSpec
? Likewise with openPaymentsResourceServerSpec
in the backend
?
Trying to see if there is a better way of distinguishing the several different spec we have
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 one here is actually authServerSpec
(from https://github.com/interledger/rafiki/blob/main/packages/auth/src/openapi/resource-server.yaml)
I think openPaymentsAuthServerSpec
would be https://github.com/interledger/open-payments/blob/main/openapi/schemas.yaml
What if we just called the first one introspection/tokenIntrospection for both the file name (make it consistent in both auth
and backend
) and the variable name?
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.
I'm gonna change https://github.com/interledger/rafiki/blob/main/packages/auth/src/openapi/resource-server.yaml to token-introspection.yaml
with
const authServerSpec = await createOpenAPI( | |
const tokenIntrospectionSpec = await createOpenAPI( |
and not
const authServerSpec = await createOpenAPI( | |
const tokenIntroSPECtion = await createOpenAPI( |
and keep the other file and variable names as is.
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.
The tokenIntrospectionSpec
change makes sense, but it should be replacingresourceServerSpec
variable (the one that contains the introspection
route), right?
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.
Ha, yeah. I was thinking these comments were for packages/backend/src/index.ts
🙃
Changes proposed in this pull request
Context
Checklist
fixes #number