Juhi Gupta
Juhi Gupta

Reputation: 125

GCP Cloud endpoint portal does not show xml definition defined in swagger

Having an issue with displaying xml structure defined in swagger file on cloud endpoint portal (Developer portal) for example it does not show the namespaces and example defined, but it works fine when uploaded on swagger editor

Following is example of xml definition declared

MsgResp:
type: object
properties:
  Code:
    type: string
    example: RC_001_SUCCESS
  Message:
    type: string
    example: Message sent
xml:
  name: 'MessageResponse'
  wrapped: true
  namespace: http://MsgResponse

Edit:

Swagger file

# [START swagger]
swagger: '2.0'
info:
  title: <Endpoint-name>
  description: <Endpoint-name>
  version: 1.0.0
# Connects to the cloud run running the ESP Beta 2 image
host: <Endpoint-address> # CloudRun/Esp url
security: []
schemes:
  - https
paths:
  "/status":
    post:
      description: "Test API for sending  request from system 1 to IIP. "
      operationId: "status-api"
      # Defines which service it should connect to for backend processing, It can be Cloud function/ Cloud Run url
      x-google-backend:
        address: https://<Function1-address> # Backend Cloud function URL
        deadline: 3600.0
      # Defines Authentication mechanism to use, Following mentions to use API KEYS
      security:
      - api_key: []
      # MIME Types expected as request and response        
      produces:
      - "application/xml"     
      consumes:
      - "application/xml"
      parameters:
        - in: body
          name: schema
          description: Input Schema for /status
          schema:
            $ref: '#/definitions/InSchema'

      responses:
        200:
          description: OK
          schema:
            $ref: '#/definitions/MessageResponse'    
        404:
          description: Not Found
        500:
          description: Internal Service Error 
definitions:
  InSchema:        
    type: object
    xml:
      name: 'Identifier'
      prefix: 'msg'
      wrapped: true
      namespace: 'http://Identifier'    
    properties:
      Number:
        type: integer
      LogIdentifier:
        type: object
        properties:
          Code:
            type: integer
          Type:
            type: string            
        xml:
          name: 'LogicalIdentifier'
          wrapped: true
          namespace: http://LogicalIdentifier
          prefix: sample
    example:   # <----------
      Number: 38
      LogIdentifier:
        Code: 100
        Type: CDC
  MessageResponse:
    type: object
    properties:
      Code:
        type: string
        example: SUCCESS
      Message:
        type: string
        example: Message sent
# [START securityDef]
securityDefinitions:
  api_key:
    type: "apiKey"
    name: "key"
    in: "query"
# [END securityDef]

As seen on swagger editor enter image description here

As seen on Cloud endpoint portal/ application portal enter image description here

Upvotes: 0

Views: 107

Answers (1)

Nibrass H
Nibrass H

Reputation: 2487

According to Cloud Endpoints on Cloud Run Official Documentation, I can only see the .json MimeType is used in the example.

The Cloud Endpoint service definition should be based on OpenAPI Specification v2.0, also known as Swagger 2, which describes the surface of your backend service and any authentication requirements.

So checking the OpenAPI Specification v2.0 in GitHub, I was not able to see xml specification in the MimeType Section. However in the Swagger Official Documentation, I can see that the xml media type is supported as well.

So I would like to ask you to check all the steps provided in the Cloud Endpoint on Cloud Run Official Documentation.

In the screenshot, I can see 404 NOT_FOUND error, this error is mentioned in the Troubleshooting section of Cloud Endpoints, so please have a look into it.

Upvotes: 1

Related Questions