Skip to content
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

Schema docs #50

Merged
merged 18 commits into from
Apr 3, 2024
Merged

Schema docs #50

merged 18 commits into from
Apr 3, 2024

Conversation

duncanjbrown
Copy link
Contributor

@duncanjbrown duncanjbrown commented Mar 27, 2024

Context

As we request data from participants, we'll need to agree a format for them to submit it.

This PR proposes that format in the standard OpenAPI spec style.

It then takes that information and uses it to generate a documentation page, via some Pydantic models.

It depends on #55, which prepares the views/ directory for these changes.

Changes proposed in this pull request

  • Create the spec
  • Turn the spec into Pydantic models using datamodel-code-generator (May be premature: these objects are handy for rendering docs, and we'll need them when we parse user input... tho JSON schema would do for now)
  • Render the schemas out of the spec (tests still required for the RenderableSchema decorator and more on the end to end test)
  • Turn the pydantic models into JSON schemas 😅
  • Use json-schema-faker to generate some example data
  • Render that on the page too, along with the schemas.
  • Changelog! 👊

Result:

(One JSON open for e.g.)

0 0 0 0_8000_schema (4)

Guidance to review

Have a click around, look at the OpenAPI YAML spec, look at the Makefile, try making a change to the YAML spec and then re-running make schema_docs.

Link to JIRA ticket

https://technologyprogramme.atlassian.net/jira/software/projects/CON/boards/418?selectedIssue=CON-21

Things to check

  • I have added any new ENV vars in all deployed environments and updated the .env.example and .env.test files in the repo

@KevinEtchells
Copy link
Contributor

The frontend looks great, @duncanjbrown. Just one comment on a tiny fix for the sub-headings within "Entities".

@duncanjbrown duncanjbrown changed the title WIP Feature/schema docs Schema docs Mar 30, 2024
@duncanjbrown duncanjbrown marked this pull request as ready for review March 30, 2024 01:04

<p class="govuk-body">This page lists the data components required for a consultation to be suitable for processing by the analyser. </p>

<p class="govuk-body">Data should be provided in one JSON file containing both the consultation itself and a list of responses. That overall data file is described here and an example is given. Underneath are details of each section, including individual JSON schemas for both the Consultation and ConsultationResponse parts of the JSON file.</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

I wasn't entirely clear on the difference between the 3 schemas and how they are related.

Could make it clear that the ConsultationWithResponses is the one we want e.g. "Data should be provided in one JSON file..... that is valid according to the ConsultationWithResponses schema."

Could be explicit on how the 3 schema relate.

duncanjbrown and others added 13 commits April 3, 2024 15:30
- Add OpenAPI spec for the schema entities
- Use datamodel-codegen to turn the schema into Pydantic models
- Use a management command to turn the Pydantic models into JSON schema
- Write the lot into public_schema/
- Add Makefile rules (including .PRECIOUS! which turns out to be
  necessary when you want to hold on to an intermediate file, which we
  do) to build the schemas and examples from the spec
This allows the template to ask direct questions about the schema object
instead of needing to know about how it's implemented
This page documents the schema for file uploads
Copy link
Contributor

@nmenezes0 nmenezes0 left a comment

Choose a reason for hiding this comment

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

These docs and the way they are generated look great - have checked that I can regenerate using make schema_docs.

There are a few minor comments.

I'm going to take liberties and fix the things that need to be fixed (Kev's comment, broken link, incorrect comment), rebase and merge so we can get this in (and so the PR isn't hanging about for ages whilst you're on leave).

There are a few other comments which are suggestions - you might want to look at those later.

@nmenezes0 nmenezes0 force-pushed the feature/schema-docs branch from 8a2b087 to 642ea27 Compare April 3, 2024 15:24
@nmenezes0 nmenezes0 merged commit e659a71 into main Apr 3, 2024
6 checks passed
@nmenezes0 nmenezes0 deleted the feature/schema-docs branch April 3, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants