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

Updated OpenAPISpecWriter & Parameter classes to allow for the optional 'format' modifier field to be included in the output schema. #394

Conversation

ArclightHub
Copy link
Contributor

What does this change do?

Updates the output openapi.yml file to allow the optional 'format' modifier as per the swagger data-types spec:
https://swagger.io/docs/specification/data-models/data-types/

How does it work?

  • Both of the Parameter classes have a new "public ?string $field = null;" property which can be optionally set to a string.
  • The OpenAPISpecWriter class will include the above optional property in the 'schema' when it is set to a valid string.

…al 'format' modifier field to be included in the output schema.
@ArclightHub ArclightHub force-pushed the feature/allow-optional-string-formats-modifier branch from 4099ccd to b577931 Compare December 17, 2021 01:13
@shalvah
Copy link
Contributor

shalvah commented Dec 21, 2021

Sorry I didn't get to the opened issue earlier, but this doesn't sit well with me.

For one, adding a field to the Parameter DTO that is only relevant for the OpenAPIWriter does not seem right. The field is not used anywhere else in Scribe, and there isn't even a way to specify or hint its value via the default methods.

@shalvah
Copy link
Contributor

shalvah commented Dec 21, 2021

On the flip side, there's probably an argument to be made for adding a custom field to the Parameter class, like we did for endpoint metadata, where Scribe can put in extra data like an inferred format, but that's a thing for another day.

I think what I'll go with for now is this:

  1. I'll add a custom field to the Parameter class. You can put in whatever values you want here.
  2. You can then create your own subclass of the OpenAPISpecWriter that reads the format from there, and bind to the container, and Scribe will automatically pick that instead.

@shalvah shalvah closed this Dec 21, 2021
@shalvah
Copy link
Contributor

shalvah commented Dec 21, 2021

v3.20 will contain the new custom field. You can write/read it however you wish. https://scribe.knuckles.wtf/laravel/reference/plugin-api#__invokeextractedendpointdata-endpointdata-array-routerules-array

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 this pull request may close these issues.

2 participants