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

feat(rest): refactoring common filter schemas #4328

Closed
achrinza opened this issue Dec 22, 2019 · 4 comments
Closed

feat(rest): refactoring common filter schemas #4328

achrinza opened this issue Dec 22, 2019 · 4 comments
Assignees

Comments

@achrinza
Copy link
Member

achrinza commented Dec 22, 2019

Related: #4290 (comment)

Currently, the filter schemas are generated inline in the OAS openapi.json document. This may lead to the filter schemas being repeated within the same OAS docs.

Suggestion

Instead, these schemas should be refactored into /components/schemas.

Use Cases

The OAS document may be more compact and have increased readability as the filter schemas will not be repeated. Furthermore, the generated client-side code may also benefit similarly.

Examples

(Taken from: #4290 (comment))

{
  "TodoFields": {
    "title": "TodoFields",
    "type": "object",
    "properties": {
      "id": {
        "type": "boolean"
      }
     // ...
    }
  },
  "TodoFilter": {
    "title": "TodoFilter",
    "type": "object",
    "properties": {
      "where": {
        "type": "object"
      },
      "fields": {
        "$ref": "#/components/schemas/TodoFields"
      },
      "offset": {
        "minimum": 0,
        "type": "integer",
        "format": "int32"
      },
      "limit": {
        "minimum": 1,
        "type": "integer",
        "format": "int32",
        "example": 100
      },
      "skip": {
        "minimum": 0,
        "type": "integer",
        "format": "int32"
      },
      "order": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": ""
      },
      "include": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/Include"
        },
        "description": ""
      }
    }
  }

Acceptance criteria

TBD - will be filled by the team.

@dougal83
Copy link
Contributor

@bajtos Here is a draft gist. I need to run code against samples and write tests(*sigh).

Where would be the best to place this code and where to inject it's functionality? I'll put into PR for review pending your feedback.

@jannyHou
Copy link
Contributor

@dougal83 commented in #4290 (comment) :)

@bajtos
Copy link
Member

bajtos commented Jan 7, 2020

After we land feat(rest): add openapi schema consolidation #4365, I'd like to start the process of deprecating getModelSchemaRef and reworking both our existing code and CLI templates to leverage the new schema consolidation:

Considering the scope of that work, I think it may be better to open a follow-up issue.

Thoughts?

@achrinza achrinza changed the title feat(repository-json-schema): refactoring common filter schemas feat(rest): refactoring common filter schemas Jan 12, 2020
@dhmlau
Copy link
Member

dhmlau commented Jun 20, 2020

Closing as done. Opened #5791 as follow up issue.

@dhmlau dhmlau closed this as completed Jun 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants