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

Arazzo lint body references #1761

Open
adamaltman opened this issue Oct 10, 2024 · 0 comments
Open

Arazzo lint body references #1761

adamaltman opened this issue Oct 10, 2024 · 0 comments
Labels
governance Issues relating to problems with or requests for API governance/linting/decorating Type: Bug Something isn't working

Comments

@adamaltman
Copy link
Member

Describe the bug

Arazzo should be linted to correctly validate the ABNF usage of body ($request.body and $response.body) to use the json-pointer:

      body-reference = "body" ["#" json-pointer ]
      json-pointer    = *( "/" reference-token )

For example, $response.body#/id.

To Reproduce

The first step has output of anchor_id: $response.body.id and that should flag a lint error. It should be $response.body#/id.

Expected behavior

An error message should state the $response.body can only be followed by the # character and a json-pointer.

Logs

No lint error is provided.

Arazzo description

# Run in spot: npx @redocly/spot run ./apis/arazzo.yaml --input token=abc
arazzo: 1.0.0
info:
  title: Warp API
  version: 1.0.0
sourceDescriptions:
  - name: api-reference
    type: openapi
    url: index.yaml
    x-serverUrl: "http://localhost:2525/_mock/api-reference/"
workflows:
  - workflowId: missionLostInvention
    summary: Lost invention
    description: |-
      Travel back to the year 1889 and retrieve the blueprint for Nikola Tesla’s lost invention before it’s destroyed in a mysterious fire.
    inputs:
      type: object
      properties:
        token:
          type: string
          description: JWT Bearer token
    parameters:
      - name: Authorization
        in: header
        value: "Bearer {$inputs.token}"
    steps:
      - stepId: setAnchorToCurrentTime
        operationId: api-reference.setAnchor
        description: Set an anchor to the current time.
        outputs:
          anchor_id: $response.body.id
      - stepId: createTimelineTo1889
        operationId: api-reference.createTimeline
        description: Create a timeline to 1889.
        outputs:
          timeline_id: $response.body.id
      - stepId: travelTo1889
        operationId: api-reference.timeTravel
        description: Travel to 1889.
        requestBody:
          payload:
            destination: $steps.createTimelineTo1889.outputs.timeline_id
      - stepId: findAndRegisterBlueprint
        operationId: api-reference.registerItem
        description: Find the blueprints. Then, register them using the `registerItem` API call.
        requestBody:
          payload:
            description: Tesla's blueprint
        outputs:
          item_id: $response.body.id
      - stepId: avoidParadox
        operationId: api-reference.checkParadox
        description: Check for paradoxes.
        requestBody:
          payload:
            timeline_id: $steps.createTimelineTo1889.outputs.timeline_id
            proposed_changes:
              - event: Sneak in to retrieve Tesla's blueprint
                time: "1889-03-10T23:50:00Z"
              - item_id: $steps.findAndRegisterBlueprint.outputs.item_id
        successCriteria: 
          - condition: $statusCode == 200
          - condition: $.is_stable == true
            context: $response.body
            type: jsonpath
      - stepId: returnToPresent
        operationId: api-reference.timeTravel
        description: Return to the present.
        requestBody:
          payload:
            destination: $steps.setAnchorToCurrentTime.outputs.anchor_id
            items:
              - $steps.findAndRegisterBlueprint.outputs.item_id

Redocly Version(s)

latest

Node.js Version(s)

20.x

OS, environment

mac

Additional context

https://spec.openapis.org/arazzo/latest.html#runtime-expressions
body-reference = "body" ["#" json-pointer ]
json-pointer = *( "/" reference-token )

@adamaltman adamaltman added governance Issues relating to problems with or requests for API governance/linting/decorating Type: Bug Something isn't working labels Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
governance Issues relating to problems with or requests for API governance/linting/decorating Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant