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

[FR] Extend support for Json Schema #166

Open
gberche-orange opened this issue Jan 20, 2021 · 2 comments
Open

[FR] Extend support for Json Schema #166

gberche-orange opened this issue Jan 20, 2021 · 2 comments
Labels
enhancement New feature or request help wanted The team has de-prioritized this and could use your help!

Comments

@gberche-orange
Copy link
Contributor

gberche-orange commented Jan 20, 2021

Is your feature request related to a problem? Please describe.

  • As a brokerpack author
  • in order to propose generated forms to my users for parameters of type array
  • I need more complete support of JsonSchema syntax than the current on in CSB 0.2.1

Describe the solution you'd like

The Json schema for array (see https://json-schema.org/understanding-json-schema/reference/array.html#list-validation ) requires support for the items element

{
  "type": "array",
  "items": {
    "type": "number"
  }
}

Without this element, OSB client form generator such as https://github.com/cloudfoundry/stratos don't generate the entry for the parameter of type array

details of rendering without `items` keyword

Json schema generated by CSB, which is missing the itemselement

{
    "$schema": "http://json-schema.org/draft-04/schema#",
                                    "properties": {
                                        "endpoints": {
                                            "description": "The endpoints of all app instances",
                                            "title": "Endpoints",
                                            "type": "array"
                                        },
                                        "healthcheck_uri": {
                                            "default": "/",
                                            "description": "The healthcheck endpoint",
                                            "title": "Healthcheck URI",
                                            "type": "string"
                                        },
                                        "method": {
                                            "default": "GET",
                                            "description": "The HTTP method",
                                            "enum": [
                                                "GET",
                                                "HEAD",
                                                "POST",
                                                "PUT"
                                            ],
                                            "title": "Method",
                                            "type": "string"
                                        },
                                        "port": {
                                            "default": 443,
                                            "description": "The TCP port",
                                            "maximum": 65535,
                                            "minimum": 1,
                                            "title": "Port",
                                            "type": "number"
                                        },
                                        "scheme": {
                                            "default": "https",
                                            "description": "The scheme",
                                            "enum": [
                                                "http",
                                                "https"
                                            ],
                                            "title": "Scheme",
                                            "type": "string"
                                        },
                                        "tags": {
                                            "default": [],
                                            "description": "The tags",
                                            "title": "Tags",
                                            "type": "array"
                                        },
                                        "type": {
                                            "default": "http",
                                            "description": "The service type (http or tcp)",
                                            "enum": [
                                                "http",
                                                "tcp"
                                            ],
                                            "title": "Type",
                                            "type": "string"
                                        }
                                    }
}

Rendering without items json schema element
image

Rendering with items json schema element (note the yellow button to add new array entries)
image

Json schema fragment with items

                                       "endpoints": {
                                            "description": "The endpoints of all app instances",
                                            "title": "Endpoints",
                                            "type": "array",
                                            "items": { "type":"string"}
                                        },

See https://hamidihamza.com/ajsf/?set=ng-jsf&example=ng-jsf-nested-arrays&framework=material-design&language=en for live demo of Json schema form generation

Describe alternatives you've considered

  • add just support for items constraint element
  • modify CSB to blindly include any constraint element without validation
  • add alternative CSB support for providing full Json schema (i.e. independently of input variables and constraints)

Additional Context

Currently adding a constraint with the following produces no error message at build or serving, but the served v2/catalog does not include the items element in the JSON Schema.

provision:
  plan_inputs: [ ]
  user_inputs:
    - required: true
      field_name: endpoints
      type: array
      details: The endpoints of all app instances
      constraints:
        items:
          type: string

Fails at catalog serving with output:

{"timestamp":"1611160181.886161089","source":"cloud-service-broker","message":"cloud-service-broker.encoding response","log_level":2,"data":{"data_dump":"lager.Data{\"error\":\"json: unsupported type: map[interface {}]interface {}\", \"r
esponse\":brokerapi.CatalogResponse{Services:[]brokerapi.Service{brokerapi.Service{ID:\"357f0f4f-c905-46b8-b4ee-dfc559537c03\", Name:\"global-server-load-balancer\", Description:\"Global Server Load Balancing\", Bindable:true, InstancesR
etrievable:false, BindingsRetrievable:false, Tags:[]string{\"gslb\", \"gtm\", \"load-balancer\", \"dns\"}, PlanUpdatable:true, Plans:[]brokerapi.ServicePlan{brokerapi.ServicePlan{ID:\"50d8f38b-37d3-47b7-a4aa-0830eb3bb34d\", Name:\"standa
rd\", Description:\"Standard HA Plan\", Free:(*bool)(0xc000597680), Bindable:(*bool)(nil), Metadata:(*brokerapi.ServicePlanMetadata)(0xc0001eddb0), Schemas:(*brokerapi.ServiceSchemas)(0xc00059cde0), MaintenanceInfo:(*brokerapi.Maintenanc
eInfo)(nil)}}, Requires:[]brokerapi.RequiredPermission(nil), Metadata:(*brokerapi.ServiceMetadata)(0xc0001916c0), DashboardClient:(*brokerapi.ServiceDashboardClient)(nil)}}}, \"status\":200}","lager serialisation error":"json: unsupporte
d type: map[interface {}]interface {}"}}

Priority

Priority Context

Platform

Applicable Services

@gberche-orange gberche-orange added the enhancement New feature or request label Jan 20, 2021
@omerbensaadon omerbensaadon added the help wanted The team has de-prioritized this and could use your help! label Jan 25, 2021
@omerbensaadon
Copy link
Contributor

Thank you for your PR in support of this feature @gberche-orange!

This is not currently prioritized by the CSB team, so I have marked it as "help-wanted."

We will follow up if anything changes 💯

@pivotal-marcela-campo
Copy link
Member

Hi @gberche-orange, is this something you still want? We don't still have bandwidth to tackle this request and it has been open for contributions for a long time now. Would you be able to submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted The team has de-prioritized this and could use your help!
Projects
Status: Waiting for Changes | Open for Contributions
Development

No branches or pull requests

3 participants