Skip to content

Add OpenAPI spec support for policy schema creation - #105

Merged
gemanor merged 22 commits into
permitio:mainfrom
daveads:feat/openapi-policy-apply
Apr 24, 2025
Merged

gemanor merged 22 commits into
permitio:mainfrom
daveads:feat/openapi-policy-apply

Conversation

@daveads

@daveads daveads commented Apr 14, 2025

Copy link
Copy Markdown
Contributor

Description

This PR adds a new command permit env apply openapi that allows users to create a complete policy schema from an OpenAPI specification file. The command reads x-permit-* extensions from the OpenAPI spec and creates corresponding resources, actions, roles, relations, and URL mappings in the Permit environment.

Closes #79

@gemanor gemanor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This needs some more work, see comments. Main issues:

  1. Complex and mostly impossible to test/debug logic in the processor file.
  2. API calls made through the fetchUtil and not the useClient
  3. Please attach to the PR some YAML/JSON OpenAPI files where we can test it

Comment thread source/commands/env/apply/openapi.tsx Outdated
Comment thread source/components/env/openapi/OpenapiComponent.tsx
Comment thread source/hooks/openapi/usePermitRelationApi.ts Outdated
Comment thread source/components/env/openapi/OpenapiProcessor.tsx Outdated
Comment thread source/components/env/openapi/OpenapiProcessor.tsx Outdated
Comment thread source/components/env/openapi/OpenapiProcessor.tsx Outdated
Comment thread source/components/env/openapi/OpenapiProcessor.tsx Outdated
daveads and others added 2 commits April 18, 2025 15:55
Co-authored-by: Gabriel Manor <g.e.manor@gmail.com>
@daveads

daveads commented Apr 21, 2025 •

Copy link
Copy Markdown
Contributor Author

This needs some more work, see comments. Main issues:

1. Complex and mostly impossible to test/debug logic in the processor file.

2. API calls made through the `fetchUtil` and not the `useClient`

3. Please attach to the PR some YAML/JSON OpenAPI files where we can test it

npx tsx ./source/cli.tsx env apply openapi --spec-file https://raw.githubusercontent.com/daveads/openapispec/main/blog-api.json

Repo :: https://github.com/daveads/openapispec

Comment thread source/commands/env/apply/openapi.tsx Outdated
Comment thread source/components/env/openapi/OpenapiComponent.tsx
Comment thread source/components/env/openapi/OpenapiForm.tsx
Comment thread source/components/env/openapi/OpenapiResults.tsx
@daveads
daveads force-pushed the feat/openapi-policy-apply branch from 9fa48bc to 73e062f Compare April 24, 2025 15:59
@gemanor
gemanor merged commit fcee8f9 into permitio:main Apr 24, 2025
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.

[Command] Create Policy from OpenAPI Spec

2 participants