Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2926
Closed
Open
Issue created May 17, 2019 by Administrator@rootContributor

[BUG] Erlang-server schema validation failure for json string body

Created by: riccardomanfrin

Description

Not sure if it's because of my spec, but I'm opening it to get some help. Starting from the swagger 2 API spec in the below yaml, I run the generator for erlang-server. THis produces the openapi.json priv file and .erl stuff. Among my APIs I have a post with a json string body. This API fails with the following info log:

Unable to process request for 'RootPost': {wrong_param,binary,schema,#{error => {schema_not_found,"#/components/schemas/binary"},type => schema_invalid}}

The failure occurs in *_api.erl file around here:

validate_with_schema(Body, Definition, ValidatorState) ->
    jesse_schema_validator:validate_with_state(
        [{<<"$ref">>, Definition}],
        Body,
        ValidatorState
    ).

I took deps from the README.md

    {jesse,  {git, "https://github.com/for-GET/jesse.git", {tag, "1.5.2"}}},
    {jsx,               {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.9.0"}}},
    {cowboy,            {git, "https://github.com/ninenines/cowboy.git", {tag, "2.5.0"}}}
openapi-generator version

4.0.1-SNAPSHOT not a regration afaik

OpenAPI declaration file content or url

This is the swagger 2 input yaml:

paths:
  /:
    post:
      tags:
        - index
      description: "Create a new Table Index"
      parameters:
      - name: "index"
        in: "body"
        description: "Table Index to create up"
        schema:
          type: "string"
      responses:
        201:
          description: "New Index Created"

This is the openapi3 output json from the cli

"paths" : {
    "/" : {
      "post" : {
        "tags" : [ "index" ],
        "description" : "Create a new Table Index",
        "requestBody" : {
          "description" : "Table Index to create up",
          "content" : {
            "*/*" : {
              "schema" : {
                "type" : "string"
              }
            }
          },
          "required" : false
        },
        "responses" : {
          "201" : {
            "description" : "New Index Created",
            "content" : { }
          }
        },
        "x-codegen-request-body-name" : "index"
      }
    },
Command line used for generation
docker run --rm \
	-v $(pwd):/local \
	openapitools/openapi-generator-cli \
	generate \
	-i /local/priv/swagger.yaml \
	-g erlang-server \
	-o /local/out/
Steps to reproduce

Start application and curl -X POST "http://localhost:5678/" -H "Content-Type: application/json" -d '"hello"'

Suggest a fix

Possibly there should be no schema (no /components/schemas) to validate at all for a json string (?)

Assignee
Assign to
Time tracking