Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Special char doesn't show in @apiGroup #163

Closed
caio-ribeiro-pereira opened this issue Nov 27, 2014 · 7 comments
Closed

Special char doesn't show in @apiGroup #163

caio-ribeiro-pereira opened this issue Nov 27, 2014 · 7 comments

Comments

@caio-ribeiro-pereira
Copy link

Hi, I'm using apidoc.js to write an api documentation in brazilian portuguese language, but when I use chars like "ç", "ã", "é" in a @APIGroup name, the layout hide this chars.

For example, if I set "@APIGroup Autenticação", the layout will show "AUTENTICA O" instead "AUTENTICAÇÃO".

@rottmann
Copy link
Member

Fixed in 0.9.0

@caio-ribeiro-pereira
Copy link
Author

Great! Thanks a lot!

@caio-ribeiro-pereira
Copy link
Author

Hi, even updating this module the problem still happening in @apiGroup, and now I found the same bug for @api, for example:

@api {get} /autenticacao Autenticação

will output: Autentica o

Another example is when your group has more than one word, like this example:

@api {get} /pagamento/codigo Pagamento com código de barras

will output: Pagamento_com_c digo_de_barras

@rottmann rottmann reopened this Dec 12, 2014
@rottmann
Copy link
Member

Can't reproduce the error, the output is correct.
Can you send me the generated api_data.json and api_project.json?

@caio-ribeiro-pereira
Copy link
Author

This is my api example project: https://github.com/caio-ribeiro-pereira/apidoc-example

And these are the outputs:

api_data.json:

[
  {
    "type": "delete",
    "url": "/logout",
    "title": "Logout",
    "group": "Autentica__o",
    "success": {
      "fields": {
        "Success 200": [
          {
            "group": "Success 200",
            "type": "String",
            "optional": false,
            "field": "status",
            "description": "<p>Mensagem de saída do sistema</p> "
          }
        ]
      },
      "examples": [
        {
          "title": "Sucesso",
          "content": "   HTTP/1.1 200 OK\n   {\n     \"status\": \"Você saiu do sistema!\"\n   }",
          "type": "json"
        }
      ]
    },
    "version": "0.0.0",
    "filename": "./app.js",
    "groupTitle": "Autentica__o",
    "name": "DeleteLogout"
  },
  {
    "type": "get",
    "url": "/signin",
    "title": "Singin",
    "group": "Autentica__o",
    "success": {
      "fields": {
        "Success 200": [
          {
            "group": "Success 200",
            "type": "String",
            "optional": false,
            "field": "status",
            "description": "<p>Mensagem de acesso autorizado</p> "
          }
        ]
      },
      "examples": [
        {
          "title": "Sucesso",
          "content": "   HTTP/1.1 200 OK\n   {\n     \"status\": \"Logado!\"\n   }",
          "type": "json"
        }
      ]
    },
    "version": "0.0.0",
    "filename": "./app.js",
    "groupTitle": "Autentica__o",
    "name": "GetSignin"
  },
  {
    "type": "post",
    "url": "/signup",
    "title": "Signup",
    "group": "Autentica__o",
    "success": {
      "fields": {
        "Success 200": [
          {
            "group": "Success 200",
            "type": "String",
            "optional": false,
            "field": "status",
            "description": "<p>Mensagem de cadastro efetuado</p> "
          }
        ]
      },
      "examples": [
        {
          "title": "Sucesso",
          "content": "   HTTP/1.1 200 OK\n   {\n     \"status\": \"Cadastrado!\"\n   }",
          "type": "json"
        }
      ]
    },
    "version": "0.0.0",
    "filename": "./app.js",
    "groupTitle": "Autentica__o",
    "name": "PostSignup"
  },
  {
    "type": "put",
    "url": "/pagamento/:codigo",
    "title": "Pagamento com código de barras",
    "group": "Pagamentos",
    "success": {
      "fields": {
        "Success 200": [
          {
            "group": "Success 200",
            "type": "String",
            "optional": false,
            "field": "status",
            "description": "<p>Mensagem de dados atualizados</p> "
          }
        ]
      },
      "examples": [
        {
          "title": "Sucesso",
          "content": "   HTTP/1.1 200 OK\n   {\n     \"status\": \"Dados atualizados!\"\n   }",
          "type": "json"
        }
      ]
    },
    "version": "0.0.0",
    "filename": "./app.js",
    "groupTitle": "Pagamentos",
    "name": "PutPagamentoCodigo"
  }
]

api_project.json:

{
  "name": "apidoc-example",
  "version": "0.0.1",
  "description": "Api Node/Express que utiliza ApiDoc.js",
  "title": "ApiDoc Example",
  "generator": {
    "version": "0.9.1",
    "time": "2014-12-16T12:16:45.460Z"
  },
  "apidoc": "0.2.0"
}

@rottmann
Copy link
Member

Thx, it is the group title

@apiGroup name name is only a name without special chars

Solution: define once and use a name without special chars

/**
 * @apiDefine Autenticacao Autenticação
 */

/**
 * @api {get} /some/path Some API.
 * @apiGroup Autenticacao
 */

@neko2891
Copy link

vi /usr/local/lib/node_modules/apidoc/node_modules/apidoc-core/lib/workers/api_group.js

Found about this string on line 83
group = group.replace(/[^\w]/g, '_');
change into
//group = group.replace(/[^\w]/g, '_');
group = group;
rebuild api_data.js

then you can use special chars

Forgive me, my English is very bad

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants