Repository navigation
Conversation
Add contracts for the 15 endpoints that had none (forms, templates, profiles), remove the 4 for endpoints that no longer exist, and update the template and form schemas to what the routes take and return. Add tests/test_contracts.py, which fails when an endpoint under /api/v1 has no contract, a contract has no endpoint, or a $ref in contracts/ does not resolve. Fixes fireform-core#746
This branch has not been deployed
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.
Description
Syncs
contracts/with the endpoints the app actually serves, as asked in #746, and adds a test so they can't drift apart again.Added contracts for 15 endpoints that had none:
GET /forms/models,POST /forms/transcribe,GET /forms/submissions,GET /forms/submissions/analytics,POST /forms/purge,DELETE /forms/{submission_id}POST /templates/upload,GET /templates/preview,POST /templates/create,POST /templates/make-fillable,DELETE /templates/{template_id}path/profiles.yaml+schemas/profile.yaml):GET/POST /profiles/,GET/PATCH /profiles/{profile_id}Removed contracts for 4 endpoints that don't exist:
POST /templates,GET /templates/{template_id},GET /templates/{template_id}/fields,POST /templates/pdf.Updated existing contracts to match the code:
templates.yaml/schemas/template.yamldescribed the original proposed design (form_type,display_name, NERIS examples, field layouts). They now describe what the routes take and return (name,description,pdf_path,fields,field_count), includingPUT /templates/{id}as a partial update.FormFillRequest:input_idis optional andinput_textis documented;FormFillResponse.valuesandAsyncFormFillResponse.erroradded;POST /forms/jobsdocuments its 503 and 207 responses.weather.yaml/zipcode.yaml: the 422 / 502 / 504 responses and error codes from Validate weather forecast query parameters #732, Return proper status codes from the address lookup endpoint #741 and Return 502 when Open-Meteo fails in the weather forecast endpoint #743.jobs.yaml: the 404 example now shows what the route returns (NOT_FOUND, "Job not found").openapi.yaml: server port8080→8000(the port compose and the Dockerfile use), aprofilestag, andX-API-Key/ Bearer security schemes for the routes guarded byverify_api_key.common.yaml:HTTPErrorDetail(the{"detail": ...}body some template/profile routes return viaHTTPException) andStatusMessage.New
tests/test_contracts.py:/api/v1inapp.openapi()has a contract$refincontracts/resolvesOn
developmentthe first two fail, listing exactly the 15 missing and 4 stale endpoints above. Uses PyYAML, which is already installed throughrequirements.txt.Note: the profiles router is also mounted a second time without the
/api/v1prefix (api_router.include_router(profiles.router)inapp/api/router.py, left over from 9437c60), so/profiles/and/profiles/{profile_id}are served twice. The frontend only calls/api/v1/profiles/. I left that out of this docs PR; happy to remove the duplicate mount in a follow-up if you'd like.Fixes #746
Type of change
How Has This Been Tested?
openapi-spec-validatoroncontracts/openapi.yaml(all files, refs resolved): validtests/test_contracts.py: 3 passed (2 of them fail ondevelopment)python -m pytest tests/→ 413 passedruff check app/→ all checks passedTest Configuration:
Checklist: