Skip to content

Extend OpenAPISpecGeneratorPlugin to include default values for parameters #1110

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

Open
garrytrinder opened this issue Apr 8, 2025 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted We'd appreciate your help

Comments

@garrytrinder
Copy link
Contributor

Azure API endpoints use the api-version query string parameter to version endpoints.

When using Dev Proxy to generate an OpenAPI spec the api-version parameter in not included in the generated document. This leads to an error when issuing a request as the api-version parameter is not sent.

We should look to include this as a parameter in generated documents with a default value.

      parameters:
        - name: api-version
          in: query
          required: true
          schema:
            type: string
            default: "2024-11-01-preview"
@waldekmastykarz waldekmastykarz added the bug Something isn't working label Apr 9, 2025
@waldekmastykarz waldekmastykarz self-assigned this Apr 9, 2025
@waldekmastykarz
Copy link
Collaborator

OK, so I can see the param included in the generated spec but it's missing the default value:

Image

We can definitely include the specified value as default. What do you think: should we do it by default, or should it be an option, like currentValueAsDefault, which is set to false by default but when set to true copies the values from the intercepted requests as defaults?

I see also that in the generated spec, the param is not marked as required. Do you know if that's necessary for agents to always include the param in the API request?

@garrytrinder
Copy link
Contributor Author

should we do it by default, or should it be an option, like currentValueAsDefault, which is set to false by default but when set to true copies the values from the intercepted requests as defaults?

I think for ease it would be easier to use the value from the request as the default value.

Thinking about it some more, should we have an array of known parameters like api-version in the configuration, but which developers can override with their own param names?

I see also that in the generated spec, the param is not marked as required. Do you know if that's necessary for agents to always include the param in the API request?

In this case yes, not sending the param results in an error from the API.

@waldekmastykarz
Copy link
Collaborator

I think for ease it would be easier to use the value from the request as the default value.

The reason I'd prefer to expose it via an option and an explicit opt-in is because of potential PII that could end up in the spec.

Thinking about it some more, should we have an array of known parameters like api-version in the configuration, but which developers can override with their own param names?

We already have a list of standard headers. We could go about it in two ways:

  1. Allow customers to specify parameters to exclude and we include everything else
  2. Allow customers to specify parameters to include and we exclude everything else

We could offer both options and customers can decide which way they want to go about it.

@garrytrinder
Copy link
Contributor Author

Good shout on PII, then an option makes sense.

I'd say go with an include list, option 2.

@waldekmastykarz waldekmastykarz added enhancement New feature or request good first issue Good for newcomers help wanted We'd appreciate your help and removed bug Something isn't working work in progress waiting for response labels Apr 9, 2025
@waldekmastykarz waldekmastykarz changed the title Extend OpenAPISpecGeneratorPlugin with api-version query string parameter support Extend OpenAPISpecGeneratorPlugin to include default values for parameters Apr 15, 2025
@waldekmastykarz waldekmastykarz removed their assignment Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted We'd appreciate your help
Projects
None yet
Development

No branches or pull requests

2 participants