Improve OpenAPI spec generation, fix param types, and enhance UI#15
Merged
Conversation
- Fix response schema/example mismatch by wrapping examples in {"message": ...}
- Fix requestBody required flag to be based on actual required fields, not always True
- Fix security requirements to use OR logic instead of AND logic
- Improve Union type handling with proper oneOf/anyOf schemas for complex unions
- Improve PEP 604 union handling to support nested unions properly
- Remove docstring override of signature-based required/optional parameter logic
- Gate demo endpoints behind developer mode or config flag for production security
All fixes address the specific issues identified in the GitHub Copilot review.
…sing - add _PLACEHOLDER_TYPE_MAP and _parse_typed_block to handle <type> annotations in docstring Returns blocks - update extract_returns_from_docstring to detect <type> placeholders and return __placeholder_schema__ sentinel - update build_response_schema to convert __placeholder_schema__ into proper OpenAPI object schema with typed properties - fix example generation to produce typed defaults from placeholder schemas instead of serialising raw sentinel - add full Union / X|Y|None handling in get_openapi_type for Python 3.10+ union syntax - parse multi-line parameter descriptions in parse_docstring_args - only add requestBody when parameters exist; set required flag only when required params are present - delete stale spec JSON files for apps that are disabled in OpenAPI Settings
Modernize UI and add better API search capabilities
- fix None return annotation to emit {nullable: true} instead of {type: string, nullable: true}
- replace shallow non-nested brace regex with balanced-brace extractor so nested JSON in Returns blocks parses correctly
- remove dead pass block that was never executing docstring-required override logic
- remove allow_guest=True from demo_create_item, demo_update_item, demo_delete_item which enforce System Manager; spec now correctly includes auth requirements
- fix demo_authenticated to always return metadata: {} so runtime matches docstring example and schema inference
- add SVG favicon via head_include block so it is correctly injected into <head> (fixes invisible favicon from body placement)
- set document.title dynamically to '<App Title> | Docs' on app load and app switch using Jinja-populated appTitles map
Fix parameter type parsing and modernize ui
Bump app version to v0.1.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several important improvements to the Frappe OpenAPI app, focusing on enhanced documentation, user onboarding, and the addition of comprehensive demo API endpoints. The README has been significantly expanded for better clarity and usability, the app version is bumped to reflect new features, and a new module of sample API endpoints is added to demonstrate all supported OpenAPI features.
Documentation and Onboarding Improvements:
README.mdto include a new logo, feature highlights, detailed installation instructions, clearer usage steps, improved guidelines for API documentation, and a proper license link. This makes onboarding and understanding the app much easier for new users. [1] [2]Versioning:
frappe_openapi/__init__.pyfrom0.0.1to0.1.0to reflect the addition of new features and demo endpoints.Demo API Endpoints:
frappe_openapi/api/examples.pycontaining seven comprehensive, well-documented demo API endpoints. These endpoints cover a wide range of patterns (GET, POST, PUT, DELETE, file upload, authentication) and serve as both documentation and test cases for the OpenAPI generator. Each endpoint includes detailed docstrings to drive the OpenAPI spec and demonstrate best practices.