Skip to content

[DJF-1] feat: create openapi json from annotations#7

Open
Izcarmt95 wants to merge 7 commits intomainfrom
feature/DJF-1-create-openapi-json-from-annotations
Open

[DJF-1] feat: create openapi json from annotations#7
Izcarmt95 wants to merge 7 commits intomainfrom
feature/DJF-1-create-openapi-json-from-annotations

Conversation

@Izcarmt95
Copy link
Copy Markdown
Member

No description provided.

@Izcarmt95 Izcarmt95 requested a review from Copilot March 30, 2025 07:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces the functionality for creating an OpenAPI JSON schema from annotations in djestful, along with updates to tests, settings, and documentation to support this feature.

  • Added test endpoints with djestful’s APIView and action decorators in the test URLs.
  • Introduced new OpenAPI schemas (default, internal, external) and integrated dynamic URL mappings for API documentation.
  • Updated configuration, models, and docs to support OpenAPI schema generation and rendering.

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tests/app/urls.py Adds test API endpoints and integrates router URLs for test views.
src/tests/app/settings.py Adds DJESTFUL_FRAMEWORK settings including OpenAPI schema configuration.
src/tests/app/schemas.py Implements default, internal, and external OpenAPI schemas.
src/djestful/openapi/views.py Updates view functions to support new OpenAPI JSON generation and docs.
src/djestful/openapi/schemas.py Introduces URL pattern generation for OpenAPI documentation.
src/djestful/openapi/models.py Adds pydantic model definitions for OpenAPI components.
src/djestful/openapi/docs.py Refactors docs rendering to use dynamic settings.
src/djestful/config.py Validates and loads DJESTFUL settings with schema resolution.
src/djestful/apps.py Configures the app to dynamically add OpenAPI URLs to the URL mapping.
src/djestful/init.py Removes legacy hello function.
README.md Updates code examples to reflect the new API endpoint implementations.
Files not reviewed (1)
  • src/djestful/templates/apidocs/swagger.html: Language not supported

Izcarmt95 and others added 2 commits March 30, 2025 01:08
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Izcarmt95 Izcarmt95 requested a review from Copilot March 30, 2025 07:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements support for generating OpenAPI JSON from inline code annotations while extending test endpoints and settings for the djestful framework. Key changes include:

  • Adding a new APIView subclass (TestAPIView) with various HTTP action endpoints for testing.
  • Introducing updated Django settings and schema configurations to support multiple OpenAPI schemas.
  • Enhancing OpenAPI-related modules (views, schemas, models, config, and apps) and updating documentation in the README.

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tests/app/urls.py Introduces TestAPIView with action-decorated endpoints and dynamic router URL inclusions.
src/tests/app/settings.py Adds the 'djestful' app and a new DJESTFUL_FRAMEWORK config with OpenAPI schema definitions.
src/tests/app/schemas.py Provides new OpenAPI schema classes for default, internal, and external schemas.
src/djestful/openapi/views.py Updates JSON and UI view functions for serving OpenAPI definitions.
src/djestful/openapi/schemas.py Defines the default OpenAPI schema generation logic and its URL resolution.
src/djestful/openapi/models.py Implements the underlying Pydantic models for OpenAPI specification.
src/djestful/openapi/docs.py Updates Swagger UI context settings in the docs renderer.
src/djestful/config.py Introduces schema validation and configuration settings for djestful.
src/djestful/apps.py Configures dynamic URL inclusion for OpenAPI endpoints during app initialization.
src/djestful/init.py Removes an unused hello() function.
README.md Updates example usage to reflect new schema and view implementations.
Files not reviewed (1)
  • src/djestful/templates/apidocs/swagger.html: Language not supported
Comments suppressed due to low confidence (1)

src/tests/app/urls.py:66

  • The URL pattern placeholder '{test_t}' appears ambiguous and might be a typo. Please verify if this is the intended placeholder or correct it to a more descriptive parameter.
router.include('{test_t}/', TestAPIView, basename='test-api-view-class')

@Izcarmt95 Izcarmt95 requested a review from Copilot June 2, 2025 01:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces functionality to automatically generate OpenAPI JSON specifications from annotated views and updates several parts of the Djestful framework accordingly. Key changes include:

  • Addition of new API view methods utilizing the djestful decorators with an openapi_schema_identifier parameter.
  • Integration of OpenAPI schema definitions in settings and configuration.
  • Updates to Swagger UI template and URL routing for dynamic OpenAPI and Swagger pages.

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tests/app/urls.py Added test API views and corresponding endpoints using djestful decorators.
src/tests/app/settings.py Added DJESTFUL_FRAMEWORK settings for schema definitions.
src/tests/app/schemas.py Defined OpenAPI schemas for default, internal, and external documentation.
src/djestful/templates/apidocs/swagger.html Updated Swagger UI configuration to use Django URL template tag.
src/djestful/routers.py Adjusted URL mapping to work with new operation parameters.
src/djestful/operation.py Introduced openapi_schema_identifier and enforced its presence.
src/djestful/openapi/views.py Modified to accept settings in Swagger rendering and use JsonResponse for openapi JSON.
src/djestful/openapi/schemas.py Built default OpenAPI schemas with temporary logic for paths generation.
src/djestful/config.py Added validation for OpenAPI schema configuration.
src/djestful/decorators.py Enhanced djestful action decorators to support openapi_schema_identifier.
src/djestful/apps.py Configured dynamic inclusion of OpenAPI URLs into the application’s URL routing.
README.md Updated documentation with new code examples for API endpoints.
Comments suppressed due to low confidence (2)

src/tests/app/urls.py:33

  • The method 'post_test_class' is decorated with @action.get; consider renaming it to 'get_test_class' or adjusting the decorator to match the intended HTTP method to avoid confusion.
    @action.get(

src/djestful/config.py:39

  • The error message is missing a space between 'DefaultOpenAPISchema' and 'You can use'; consider adding appropriate punctuation or spacing for clarity.
                        f'Invalid schema "{key}": must be subclass of DefaultOpenAPISchema' + 'You can use `djestful.openapi.schemas.DefaultOpenAPISchema`' + ' as a base class.'

if not self._url_operation_mapping:
return {}

## This logic is temoprary, you can change it later ,
Copy link

Copilot AI Jun 2, 2025

Choose a reason for hiding this comment

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

There is a spelling mistake in the comment ('temoprary'); please correct it to 'temporary'.

Suggested change
## This logic is temoprary, you can change it later ,
## This logic is temporary, you can change it later ,

Copilot uses AI. Check for mistakes.
'/users/me',
description='This is a test post endpoint',
summary='This is a test post endpoint',
tags=['test'],
Copy link

Copilot AI Jun 2, 2025

Choose a reason for hiding this comment

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

It appears the decorator @action.post is missing a closing parenthesis before the function definition; please fix the syntax to ensure the code compiles.

Suggested change
tags=['test'],
tags=['test'],
)

Copilot uses AI. Check for mistakes.
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.

2 participants