-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add API methods to get schema information #2767
Conversation
This fetches all the Publisher Schemas and marshals them into a key/value arrangement, removing the filepath and replacing with the schema name
This allows us to fetch a schema for a particular content type, throwing an error if there is no such schema found
@@ -0,0 +1,50 @@ | |||
RSpec.describe V2::SchemasController do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does there also need to be a request spec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I'm kinda doing a request spec over a controller spec here, as I guess controller specs are more designed to be "unit-type" tests, so I think I'll switch over 👍
@@ -0,0 +1,8 @@ | |||
class SchemaService | |||
def self.all_schemas | |||
format_regex = Regexp.new(".+\/formats\/([a-z_]+)\/.+") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so here we are using the file path to get the type of object the schema is for? Is there any other way to get the type, e.g. in the schema itself with a title
key for instance? Just wondering if there's a risk depending on a file path set in another gem which could easily change...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After chat with @pezholio There is no codified place for the name/type except in folder name
This adds controller methods that call the relevant service method and return the result as JSON
8b47701
to
555611f
Compare
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1] This adds methods to the publishing_api adapter [1] alphagov/publishing-api#2767
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1]. This adds helper methods to stub responses to these end points. [1] alphagov/publishing-api#2767
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1] This adds methods to the publishing_api adapter [1] alphagov/publishing-api#2767
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1]. This adds helper methods to stub responses to these end points. [1] alphagov/publishing-api#2767
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1]. This adds helper methods to stub responses to these end points. [1] alphagov/publishing-api#2767
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1]. This adds helper methods to stub responses to these end points. [1] alphagov/publishing-api#2767
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1] This adds methods to the publishing_api adapter [1] alphagov/publishing-api#2767
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1]. This adds helper methods to stub responses to these end points. [1] alphagov/publishing-api#2767
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1]. This adds helper methods to stub responses to these end points. [1] alphagov/publishing-api#2767
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1] This adds methods to the publishing_api adapter [1] alphagov/publishing-api#2767
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1]. This adds helper methods to stub responses to these end points. [1] alphagov/publishing-api#2767
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1] This adds methods to the publishing_api adapter [1] alphagov/publishing-api#2767 Co-authored-by: Tom Hipkin <tomhipkin@gmail.com> Co-authored-by: Harriet H-W <harriethw@gmail.com>
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1]. This adds helper methods to stub responses to these end points. [1] alphagov/publishing-api#2767
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1] This adds methods to the publishing_api adapter [1] alphagov/publishing-api#2767 Co-authored-by: Tom Hipkin <tomhipkin@gmail.com> Co-authored-by: Harriet H-W <harriethw@gmail.com>
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1]. This adds helper methods to stub responses to these end points. [1] alphagov/publishing-api#2767
This adds some API methods to return information about the schemas that Publishing API knows about, as well as fetching a schema by name. This allows us to get up to date schema information without having to have a local copy of the schemas stored somewhere and using the GOV.UK Schemas gem.
This will allow the content modelling team to have a way to create many different types of reusable content using the Publishing API as a single source of truth for the schema, rather than having to keep fields, validation rules etc in two places.
Happy to chat through in more detail if anyone needs any more context / has any questions!