Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
We Distribute
  1. Home
  2. Technical Support
  3. OpenAPI Spec + hey-api/openapi-ts

OpenAPI Spec + hey-api/openapi-ts

Scheduled Pinned Locked Moved Technical Support
8 Posts 2 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • konrad-moskal@community.nodebb.orgK This user is from outside of this forum
    konrad-moskal@community.nodebb.orgK This user is from outside of this forum
    konrad-moskal@community.nodebb.org
    wrote last edited by
    #1

    I am trying to codegen from the openapi spec, using openapi-generator-cli and @hey-api/openapi-ts, they both fail, one with:
    java.lang.RuntimeException: Could not find components/schemas/TopicObjectSlim in contents of ./read/topic/topic_id.yaml
    the other one with circular dependency

    It would seem somethings wrong with the spec, I download the full spec straight from here https://github.com/NodeBB/NodeBB/tree/master/public/openapi julian

    julian@community.nodebb.orgJ 1 Reply Last reply
    0
    • konrad-moskal@community.nodebb.orgK konrad-moskal@community.nodebb.org

      I am trying to codegen from the openapi spec, using openapi-generator-cli and @hey-api/openapi-ts, they both fail, one with:
      java.lang.RuntimeException: Could not find components/schemas/TopicObjectSlim in contents of ./read/topic/topic_id.yaml
      the other one with circular dependency

      It would seem somethings wrong with the spec, I download the full spec straight from here https://github.com/NodeBB/NodeBB/tree/master/public/openapi julian

      julian@community.nodebb.orgJ This user is from outside of this forum
      julian@community.nodebb.orgJ This user is from outside of this forum
      julian@community.nodebb.org
      wrote last edited by
      #2

      Hi Konrad-Moskal, this is the docs entry for that route: https://docs.nodebb.org/api/read/#tag/topics/paths/~1api~1topic~1{topic_id}~1{slug}~1{post_index}/get

      It seems to resolve ok here.

      In that file (topic_id.yaml) there is - $ref: ../../components/schemas/TopicObject.yaml#/TopicObjectSlim which seems to be where your parser is tripping up.

      I am not certain what the issue is, because from that working directory, that relative path does resolve to the file in question.

      Actually, I am not sure why it is looking for components/schemas/TopicObjectSlim, because the path is components/schemas/TopicObject.yaml#/TopicObjectSlim

      1 Reply Last reply
      0
      • konrad-moskal@community.nodebb.orgK This user is from outside of this forum
        konrad-moskal@community.nodebb.orgK This user is from outside of this forum
        konrad-moskal@community.nodebb.org
        wrote last edited by
        #3

        julian full error included, I am trying to fix it but no luck so far, I already tried two code gen tools, none worked, have you got it working with any tools maybe?

        [main] INFO  o.o.c.l.PythonFastAPIServerCodegen - Skipping sorting of path operations, order matters, let the developer decide via their specification file.
        [main] WARN  io.swagger.v3.parser.OpenAPIV3Parser - Exception while resolving:
        java.lang.RuntimeException: Could not find components/schemas/TopicObjectSlim in contents of ./read/topic/topic_id.yaml
        	at io.swagger.v3.parser.ResolverCache.loadRef(ResolverCache.java:203)
        	at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalSchema(ExternalRefProcessor.java:95)
        	at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefSchema(ExternalRefProcessor.java:1047)
        	at io.swagger.v3.parser.processors.ExternalRefProcessor.processSchema(ExternalRefProcessor.java:238)
        	at io.swagger.v3.parser.processors.ExternalRefProcessor.processProperties(ExternalRefProcessor.java:283)
        	at io.swagger.v3.parser.processors.ExternalRefProcessor.processSchema(ExternalRefProcessor.java:264)
        	at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefSchemaObject(ExternalRefProcessor.java:1009)
        	at io.swagger.v3.parser.processors.ExternalRefProcessor.processPathItem(ExternalRefProcessor.java:350)
        	at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalPathItem(ExternalRefProcessor.java:325)
        	at io.swagger.v3.parser.processors.PathsProcessor.processReferencePath(PathsProcessor.java:346)
        	at io.swagger.v3.parser.processors.PathsProcessor.processPaths(PathsProcessor.java:68)
        	at io.swagger.v3.parser.OpenAPIResolver.resolve(OpenAPIResolver.java:72)
        	at io.swagger.v3.parser.OpenAPIResolver.resolve(OpenAPIResolver.java:59)
        	at io.swagger.v3.parser.OpenAPIV3Parser.resolve(OpenAPIV3Parser.java:240)
        	at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:183)
        	at io.swagger.v3.parser.OpenAPIV3Parser.readLocation(OpenAPIV3Parser.java:97)
        	at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:16)
        	at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:687)
        	at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:745)
        	at org.openapitools.codegen.cmd.Generate.execute(Generate.java:527)
        	at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
        	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] WARN  o.o.codegen.utils.ModelUtils - Failed to get the schema name: ./components/schemas/UserObject.yaml#/UserObjectSlim
        [main] WARN  o.o.codegen.utils.ModelUtils - Failed to get the schema name: ./components/schemas/UserObject.yaml#/UserObjectSlim
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
        Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
         | Error count: 1, Warning count: 0
        Errors:
        	-Could not find components/schemas/TopicObjectSlim in contents of ./read/topic/topic_id.yaml
        
        	at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:718)
        	at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:745)
        	at org.openapitools.codegen.cmd.Generate.execute(Generate.java:527)
        	at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
        	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
         ELIFECYCLE  Command failed with exit code 1.
        

        You may ignore the error java.lang.RuntimeException: Could not find components/schemas/TopicObjectSlim in contents of ./read/topic/topic_id.yaml, I think I pasted the wrong thing

        julian@community.nodebb.orgJ 1 Reply Last reply
        0
        • konrad-moskal@community.nodebb.orgK konrad-moskal@community.nodebb.org

          julian full error included, I am trying to fix it but no luck so far, I already tried two code gen tools, none worked, have you got it working with any tools maybe?

          [main] INFO  o.o.c.l.PythonFastAPIServerCodegen - Skipping sorting of path operations, order matters, let the developer decide via their specification file.
          [main] WARN  io.swagger.v3.parser.OpenAPIV3Parser - Exception while resolving:
          java.lang.RuntimeException: Could not find components/schemas/TopicObjectSlim in contents of ./read/topic/topic_id.yaml
          	at io.swagger.v3.parser.ResolverCache.loadRef(ResolverCache.java:203)
          	at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalSchema(ExternalRefProcessor.java:95)
          	at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefSchema(ExternalRefProcessor.java:1047)
          	at io.swagger.v3.parser.processors.ExternalRefProcessor.processSchema(ExternalRefProcessor.java:238)
          	at io.swagger.v3.parser.processors.ExternalRefProcessor.processProperties(ExternalRefProcessor.java:283)
          	at io.swagger.v3.parser.processors.ExternalRefProcessor.processSchema(ExternalRefProcessor.java:264)
          	at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefSchemaObject(ExternalRefProcessor.java:1009)
          	at io.swagger.v3.parser.processors.ExternalRefProcessor.processPathItem(ExternalRefProcessor.java:350)
          	at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalPathItem(ExternalRefProcessor.java:325)
          	at io.swagger.v3.parser.processors.PathsProcessor.processReferencePath(PathsProcessor.java:346)
          	at io.swagger.v3.parser.processors.PathsProcessor.processPaths(PathsProcessor.java:68)
          	at io.swagger.v3.parser.OpenAPIResolver.resolve(OpenAPIResolver.java:72)
          	at io.swagger.v3.parser.OpenAPIResolver.resolve(OpenAPIResolver.java:59)
          	at io.swagger.v3.parser.OpenAPIV3Parser.resolve(OpenAPIV3Parser.java:240)
          	at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:183)
          	at io.swagger.v3.parser.OpenAPIV3Parser.readLocation(OpenAPIV3Parser.java:97)
          	at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:16)
          	at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:687)
          	at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:745)
          	at org.openapitools.codegen.cmd.Generate.execute(Generate.java:527)
          	at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
          	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] WARN  o.o.codegen.utils.ModelUtils - Failed to get the schema name: ./components/schemas/UserObject.yaml#/UserObjectSlim
          [main] WARN  o.o.codegen.utils.ModelUtils - Failed to get the schema name: ./components/schemas/UserObject.yaml#/UserObjectSlim
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          [main] ERROR o.o.codegen.utils.ModelUtils - Undefined array inner type for `null`. Default to String.
          Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
           | Error count: 1, Warning count: 0
          Errors:
          	-Could not find components/schemas/TopicObjectSlim in contents of ./read/topic/topic_id.yaml
          
          	at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:718)
          	at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:745)
          	at org.openapitools.codegen.cmd.Generate.execute(Generate.java:527)
          	at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
          	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
           ELIFECYCLE  Command failed with exit code 1.
          

          You may ignore the error java.lang.RuntimeException: Could not find components/schemas/TopicObjectSlim in contents of ./read/topic/topic_id.yaml, I think I pasted the wrong thing

          julian@community.nodebb.orgJ This user is from outside of this forum
          julian@community.nodebb.orgJ This user is from outside of this forum
          julian@community.nodebb.org
          wrote last edited by julian@community.nodebb.org
          #4

          I asked ChatGPT for thoughts (because I literally have no idea what to say), and it theorized that openapi-generator-cli was pointed to the file topic_id.yaml directly.

          That would indeed cause issues because the file topic_id.yaml isn't meant to be loaded in isolation.

          You need to point your tool at either read.yaml or write.yaml, which are the OpenAPI schema entry points for the two APIs NodeBB exposes.

          1 Reply Last reply
          0
          • konrad-moskal@community.nodebb.orgK This user is from outside of this forum
            konrad-moskal@community.nodebb.orgK This user is from outside of this forum
            konrad-moskal@community.nodebb.org
            wrote last edited by
            #5

            I am pointing to the input correcty. My LLM wanted me to extract TopicObjectSlim into its own file, it didn't help, I tried to inline TopicObjectSlim and that worked, but there was another error of the same kind just with a different object.

            I was able to fix it, it seems at least, I'll need to test it. Adding a flag to skip validation allowed it to compete sucessfully: openapi-generator-cli generate -i src/specs/read.yaml -g typescript-fetch -o src/sdks/read --skip-validate-spec

            julian@community.nodebb.orgJ 1 Reply Last reply
            0
            • konrad-moskal@community.nodebb.orgK konrad-moskal@community.nodebb.org

              I am pointing to the input correcty. My LLM wanted me to extract TopicObjectSlim into its own file, it didn't help, I tried to inline TopicObjectSlim and that worked, but there was another error of the same kind just with a different object.

              I was able to fix it, it seems at least, I'll need to test it. Adding a flag to skip validation allowed it to compete sucessfully: openapi-generator-cli generate -i src/specs/read.yaml -g typescript-fetch -o src/sdks/read --skip-validate-spec

              julian@community.nodebb.orgJ This user is from outside of this forum
              julian@community.nodebb.orgJ This user is from outside of this forum
              julian@community.nodebb.org
              wrote last edited by
              #6

              Konrad-Moskal okay, best of luck getting the schema to load 🙂

              1 Reply Last reply
              0
              • konrad-moskal@community.nodebb.orgK This user is from outside of this forum
                konrad-moskal@community.nodebb.orgK This user is from outside of this forum
                konrad-moskal@community.nodebb.org
                wrote last edited by
                #7

                julian I was able to make a request to write api: POST to create a user, using a master token 😁

                There are w few issues though, when using a token _uid, must be specified, shame it's not in the OA spec. Error handling is also tricky, since OA spec does not have all responses types, like 400 (https://docs.nodebb.org/api/write/#tag/users/paths/~1users~1/post).

                I made good progress though so I am happy, it's a side project 🙂 Thank you for your help. Will you guys look into improving these types or are open for contributions?

                EDIT: actually _uid is not an issue, I created myself a token for admin user and it does what I want without needing to pass _uid

                julian@community.nodebb.orgJ 1 Reply Last reply
                0
                • konrad-moskal@community.nodebb.orgK konrad-moskal@community.nodebb.org

                  julian I was able to make a request to write api: POST to create a user, using a master token 😁

                  There are w few issues though, when using a token _uid, must be specified, shame it's not in the OA spec. Error handling is also tricky, since OA spec does not have all responses types, like 400 (https://docs.nodebb.org/api/write/#tag/users/paths/~1users~1/post).

                  I made good progress though so I am happy, it's a side project 🙂 Thank you for your help. Will you guys look into improving these types or are open for contributions?

                  EDIT: actually _uid is not an issue, I created myself a token for admin user and it does what I want without needing to pass _uid

                  julian@community.nodebb.orgJ This user is from outside of this forum
                  julian@community.nodebb.orgJ This user is from outside of this forum
                  julian@community.nodebb.org
                  wrote last edited by
                  #8

                  Konrad-Moskal yes, we're open to those updates to the OpenAPI spec.

                  If you use LLMs to write your commits we kindly ask you utilise the Assisted-By line in your commit messages.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  Powered by NodeBB Contributors
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups