Azure / apiops

APIOps applies the concepts of GitOps and DevOps to API deployment. By using practices from these two methodologies, APIOps can enable everyone involved in the lifecycle of API design, development, and deployment with self-service and automated tools to ensure the quality of the specifications and APIs that they’re building.
https://azure.github.io/apiops
MIT License
312 stars 182 forks source link

[Question] Option to Control "Include Required Query Parameters in Operation Templates" via OpenAPI Specification #572

Closed HimanshuKapoor328 closed 2 months ago

HimanshuKapoor328 commented 3 months ago

Release version

v5.1.1

Question Details

Hello, I am currently working on publishing an API using Azure API Management (APIM) and the ApiOps methodology(v5.1.1). In the Azure portal, there is a checkbox option for "Include required query parameters in operation templates" that I want to ensure is unticked when publishing my API.

Current Issue:

I could not find a way to control this setting via the OpenAPI specification or through the apiInformation.json file. Specifically, I am looking for a method to programmatically ensure this checkbox is unticked to prevent required query parameters from being included in the operation templates.

Expected behavior

Is there a way to control the "Include required query parameters in operation templates" setting via the OpenAPI specification or through the apiInformation.json file when using ApiOps to publish the API in APIM? If not, could you please suggest any alternative methods or provide guidance on how to achieve this programmatically?

Actual behavior

...

Reproduction Steps

apiInformation.json:

{ "properties": { "apiRevision": "1", "authenticationSettings": {}, "contact": {}, "description": "service rest api", "displayName": "Service", "isCurrent": true, "path": "service", "protocols": [ "http", "https" ], "subscriptionKeyParameterNames": { "header": "Ocp-Apim-Subscription-Key", "query": "subscription-key" }, "subscriptionRequired": true } }

github-actions[bot] commented 3 months ago
  Thank you for opening this issue! Please be patient while we will look into it and get back to you as this is an open source project. In the meantime make sure you take a look at the [closed issues](https://github.com/Azure/apiops/issues?q=is%3Aissue+is%3Aclosed) in case your question has already been answered. Don't forget to provide any additional information if needed (e.g. scrubbed logs, detailed feature requests,etc.).
  Whenever it's feasible, please don't hesitate to send a Pull Request (PR) our way. We'd greatly appreciate it, and we'll gladly assess and incorporate your changes.
HimanshuKapoor328 commented 3 months ago

I want to manipulate that checkbox in below image image Using ApiOps....

fhzhang commented 2 months ago
openapi: 3.0.1
info:
  title: Echo API
  version: '1.0'
servers:
  - url: https://nana.azure-api.net/echo
paths:
  /resource:
    get:
      summary: Retrieve resource
      description: A demonstration of a GET call on a sample resource. It is handled by an "echo" backend which returns a response equal to the request (the supplied headers and body are being returned as received).
      operationId: retrieve-resource
      parameters:
        - name: param1
          in: query
          description: A sample parameter that is required and has a default value of "sample".
          required: true
          schema:
            enum:
              - sample
            type: string
            default: sample
        - name: param2
          in: query
          description: 'Another sample parameter, set to not required.'
          required: false
          schema:
            type: number

If we publish this configuration to APIM, param1 will come up in Template parameter and param2 will come up in Query parameter. The point is this configuration is extracted from APIM in this way, the configuration is both in query parameter, param1 is checked with required option, param2 is NOT checked for required option.

It means the same configuration after extract and publish to APIM, it will make some changes, which is NOT identical.

waelkdouh commented 2 months ago

@fhzhang we don't specifically cater for this scenario, but it looks like it's a property in the API JSON.

Can you try overriding it in your publisher configuration? Something like this:


apis
- name: myapi
  properties:
    translateRequiredQueryParameters: query