-
Notifications
You must be signed in to change notification settings - Fork 11
Return $metadata resource as odata + openapi spec #528
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: master
Are you sure you want to change the base?
Conversation
3ce2bb1 to
efc396d
Compare
d178dd7 to
1593dfb
Compare
08ed3e9 to
79a815c
Compare
7e03cea to
45841e6
Compare
45841e6 to
dcc6fcc
Compare
54bcbfc to
b39bec1
Compare
|
FYI @vipulgupta2048 |
ffadb18 to
6e86ce9
Compare
dbd8d4b to
f70416c
Compare
f70416c to
8476d71
Compare
8476d71 to
95ecd2c
Compare
src/sbvr-api/permissions.ts
Outdated
| }; | ||
|
|
||
| type PermissionLookup = Dictionary<true | string[]>; | ||
| export type PermissionLookup = _.Dictionary<true | string[]>; |
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.
out of curiosity, what is the difference between lodash Dictionary and pinejs-client-core Dictionary ?
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.
@JSReds good catch. thx! This is a mistake. I only needed to export the PermissionLookup and not change the type.
Fixed to not use lodash dictionary.
da239da to
9b62b0e
Compare
e2841ca to
83b4198
Compare
|
@fisehara - would love to see this merged. I just set out to build a golang API wrapper for Balena and ran into the lack of |
src/sbvr-api/sbvr-utils.ts
Outdated
| } | ||
| }; | ||
|
|
||
| // paths./any/.get.responses.200.content.application/json.schema.d |
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 is this about?
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.
Noise ;) Deleted.
| * Used oasis translator generates openapi according to v4 spec (`value: `) | ||
| */ | ||
|
|
||
| Object.keys(openAPIJson.paths).forEach((i) => { |
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 prefer a for-of in general:
| Object.keys(openAPIJson.paths).forEach((i) => { | |
| for (const i of Object.keys(openAPIJson.paths)) { |
| if ( | ||
| openAPIJson?.paths[i]?.get?.responses?.['200']?.content?.[ | ||
| 'application/json' | ||
| ]?.schema?.properties?.value | ||
| ) { | ||
| openAPIJson.paths[i].get.responses['200'].content[ | ||
| 'application/json' | ||
| ].schema.properties['d'] = | ||
| openAPIJson.paths[i].get.responses['200'].content[ | ||
| 'application/json' | ||
| ].schema.properties.value; | ||
| delete openAPIJson.paths[i].get.responses['200'].content[ | ||
| 'application/json' | ||
| ].schema.properties.value; | ||
| } |
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 prefer the pattern of:
| if ( | |
| openAPIJson?.paths[i]?.get?.responses?.['200']?.content?.[ | |
| 'application/json' | |
| ]?.schema?.properties?.value | |
| ) { | |
| openAPIJson.paths[i].get.responses['200'].content[ | |
| 'application/json' | |
| ].schema.properties['d'] = | |
| openAPIJson.paths[i].get.responses['200'].content[ | |
| 'application/json' | |
| ].schema.properties.value; | |
| delete openAPIJson.paths[i].get.responses['200'].content[ | |
| 'application/json' | |
| ].schema.properties.value; | |
| } | |
| const properties = openAPIJson?.paths[i]?.get?.responses?.['200']?.content?.[ | |
| 'application/json' | |
| ]?.schema?.properties | |
| if (properties?.value) { | |
| properties['d'] = properties.value; | |
| delete properties.value; | |
| } |
78f5a7e to
78b8394
Compare
78b8394 to
505f79b
Compare
584853e to
25d92ed
Compare
25d92ed to
f3705bb
Compare
f3705bb to
b2aabe7
Compare
b2aabe7 to
e4d0c5c
Compare
f4ee366 to
c589975
Compare
Returning odata and openapi specs in json format. Specs are scoped to the request permissions. Different users (roles) will receive different metadata endpoints and resources. Change-type: minor Signed-off-by: Harald Fischer <harald@balena.io>
Signed-off-by: Harald Fischer <harald@balena.io>
c589975 to
f29d400
Compare
Signed-off-by: fisehara <harald@balena.io>
Signed-off-by: fisehara <harald@balena.io>
Returning odata and openapi specs in json format.
Specs are scoped to the request permissions.
Different users (roles) will receive different metadata endpoints
and resources.
Change-type: minor
See: https://jel.ly.fish/thread-93132f4a-1885-43c4-ac8d-1c190052e7d9
See: https://jel.ly.fish/thread-4245cd32-8b76-4c1a-a195-c8615c41b321
Signed-off-by: Harald Fischer harald@balena.io