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

Access column from filters #17

Closed
bbrala opened this issue Jul 27, 2021 · 7 comments · Fixed by #18
Closed

Access column from filters #17

bbrala opened this issue Jul 27, 2021 · 7 comments · Fixed by #18

Comments

@bbrala
Copy link
Contributor

bbrala commented Jul 27, 2021

I'm helping to build a openapi spec generator but it seems it is not possible to get the column property of a filter. This makes collecting examples for the specification very hard.

Any chance we can make this method public?

     /**
     * @return string
     */
    protected function column(): string
    {
        return $this->column;
    }

This would enable us to generate column examples for filters without doing very weird (and ugly) things.

@lindyhopchris
Copy link
Contributor

lindyhopchris commented Jul 27, 2021

Can you elaborate on why it's needed? I would have thought the filter name that was needed for the spec would have been the JSON:API filter name? This is referring to the Eloquent model column name, which I would have thought would be an internal implementation detail?

@bbrala
Copy link
Contributor Author

bbrala commented Jul 27, 2021

The filter name is not really the eloquent name. It could be anything. I was using the filter with a name: "modified_since" with a column name of updated_at and operator >=. Which does make sense.

The problem is generating examples for the fields like here:
https://github.com/byte-it/openapi-spec-generator/blob/master/src/Descriptors/Schema/Filters/Where.php#L20

@lindyhopchris
Copy link
Contributor

By examples, do you mean you're creating models for the examples?

@bbrala
Copy link
Contributor Author

bbrala commented Jul 27, 2021

The examples are extracted from real model data and published as part of the resulting spec file. Having real exanples helps a lot in understanding the api.

@lindyhopchris
Copy link
Contributor

Ok, thanks for explaining.

Yeah, I'd be happy with the method being made public - your best bet is to do a PR as I'm pretty limited on open source time at the mo. Otherwise I'll see if I can get to it.

If you do a PR, if you could make the same change to all filters that have a column method - just so it's consistent.

@bbrala
Copy link
Contributor Author

bbrala commented Jul 27, 2021

Ok, cool, ill see when i can make some time.

Related issue

@bbrala
Copy link
Contributor Author

bbrala commented Jul 28, 2021

As promised :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants