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
306 stars 180 forks source link

APIOps Publisher adding the BaseUrl value to WebService Url if it is empty #179

Open rohit3d2003 opened 1 year ago

rohit3d2003 commented 1 year ago

Release version

APIOps v 3.0.1

Describe the bug

I have an API where Webservice URL is left empty and we are using 'set-backend-service' policy to add the backend dynamically. When we deploy the artifacts where apiInformation.json does not have 'serviceUrl' property, publisher is automatically using 'BaseUrl' value and adding it to 'Webservice Url' post deployment

Expected behavior

WebService url should be left empty

Actual behavior

Value from BaseUrl is assigned to Webservice url making both fields have the same value

Reproduction Steps

  1. Create a API
  2. Leave Webservice URL blank
  3. Run extractor and it will bring apiInformation.json with 'serviceUrl' property
  4. Run publisher and see the value of base url is now assigned to Webservice url
guythetechie commented 1 year ago

@rohit3d2003 - thanks, I was able to reproduce the behavior. Looks like the APIM REST API sets things to the base URL if you don't explicitly pass a null service URL.

Is that causing any issues for you? I would expect the set-backend-service policy to still override things correctly.

In any case, we'll have the extractor explicitly set serviceUrl: null if you don't pass a Web Service URL.

rohit3d2003 commented 1 year ago

@guythetechie - It's not causing an issue for us but my team members got confused seeing this on the portal. Love to have it fixed

guythetechie commented 1 year ago

It unfortunately looks like this behavior is by design in APIM. Our tool just provides an abstraction layer over the APIM REST APIs. We won't try to change their behavior.

Here's how to manually reproduce it:

  1. Create an API without a web service URL. image

  2. Export the API's specification file. image

  3. The generated specification file will include the server's base URL. image

  4. Import the generated specification file. image

  5. Once the import is complete, the API has the base service URL as its web service URL. image

nathan-j-nd commented 1 year ago

I noticed this issue after promoting to our QA environment. The Dev url is showing up in QA because it comes from the openAPI spec which is added by Azure APIM. Fortunately it can be overridden using a publish configuration (see below), but this issue is annoying because the backend url was already provided via a backend and now it needs to be specified in two places that are under control of two different teams. Rather than deal with that I removed the backend and am just specifying the backend url via the following:

apis:
- name: my-api-name
  properties:
    serviceUrl: https://my-api-backend-url
vinilka8 commented 9 months ago

why can't we use an empty string in the above sample? @waelkdouh / @nathan-j-nd

apis:
- name: my-api-name
  properties:
    serviceUrl: none, null, '' or ""

APIM Supports empty Web Service URL, manually you could remove it and save it, but when I am running the pipeline, it doesn't publish the changes, stating the error that the value for serviceUrl is invalid

vinilka8 commented 7 months ago

@waelkdouh / @nathan-j-nd - any updates on this ticket?

validis-ad commented 6 months ago

Also interested in this.

vinilka8 commented 3 months ago

@waelkdouh / @nathan-j-nd - any updates on this ticket?

waelkdouh commented 3 months ago

Just to be clear this is an open source project. Do you are opening an issue and not a ticket and this we can't give you any timelines. We are currently busy with v6 release. We will get to this issue when we get time.

guythetechie commented 2 months ago

Will investigate. We might be reading serviceUrl: null as serviceUrl: "null" in configuration.

zcarroll4 commented 1 month ago

following

jaliyaudagedara commented 1 month ago

subscribing

jaliyaudagedara commented 1 month ago

@guythetechie Could this be because of JsonIgnore?

[JsonPropertyName("serviceUrl")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string? ServiceUrl { get; init; }